Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot import Boost.Python from Python 3.11 #436

Open
debemdeboas opened this issue May 17, 2024 · 4 comments
Open

Cannot import Boost.Python from Python 3.11 #436

debemdeboas opened this issue May 17, 2024 · 4 comments

Comments

@debemdeboas
Copy link

Hi all,
I'm trying to import Boost.Python from Python 3.11 and I'm getting a ModuleNotFoundError:
I'm using Boost 1.82.0 on Ubuntu x86_64.

>>> import Boost.Python
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'Boost'

I've built Boost.Python using the following bootstrap/b2 commands:

$ ./bootstrap.sh --with-python-version=3.11 --with-libraries=python
$ ./b2 -j$(nproc) --with-python install

I have also tried --with-python=/usr/bin/python3.11 on bootstrap but that also doesn't seem to work.
I have tried setting LD_LIBRARY_PATH to /usr/local/lib as well (where I installed Boost.Python) but that also didn't do the trick (I ran ldconfig and ldconfig -n /usr/local/lib too).

Can anyone give us a hand?

@stefanseefeld
Copy link
Member

Boost.Python isn't a Python module you can import. It's a library you can use from your C++ project to build Python extension modules. See e.g. http://boostorg.github.io/python/doc/html/tutorial/tutorial/hello.html

@debemdeboas
Copy link
Author

That's what I gathered from the documentation as well, but some of the team are adamant that they used to import Boost.Python in the past in .pyi files, like so:

import Boost.Python

class Foo(Boost.Python.Instance):
    ...

@stefanseefeld
Copy link
Member

They are mistaken...

@debemdeboas
Copy link
Author

Ah, well. Thank you. In that case, I'll talk to them and see where these .pyi files came from. There may be a possibility that they were directly translated from C code without care.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants