Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Description
Bug report
Background
When usingconfigure based Python installations, if two the free-threaded and default builds are installed to the same prefix, they will share the samelib directory. For example, when installing Python 3.14 the structure looks like:
include/python3.14/...include/python3.14t/...lib/libpython3.14.alib/libpython3.14t.alib/python3.14/... # shared!The include directories arenot shared, which is good because they have differentpyconfig.h files.
However, thelib/python3.14 is shared, which means that packages installed in the default build may be partially available in the free-threaded build and vice versa. This was unintended and can cause problems, such as confusing error messages and crashes.
For example, if I run:
python3.14 -m pip install numpy(install in default build)python3.14t -c "import numpy"
I get a confusing error message:
Error importing numpy: you should not try to import numpy from its source directory...
Traceback (most recent call last): File "/tmp/python-nogil/lib/python3.14/site-packages/numpy/_core/__init__.py", line 23, in <module> from . import multiarray File "/tmp/python-nogil/lib/python3.14/site-packages/numpy/_core/multiarray.py", line 10, in <module> from . import overrides File "/tmp/python-nogil/lib/python3.14/site-packages/numpy/_core/overrides.py", line 8, in <module> from numpy._core._multiarray_umath import ( add_docstring, _get_implementing_args, _ArrayFunctionDispatcher)ModuleNotFoundError: No module named 'numpy._core._multiarray_umath'During handling of the above exception, another exception occurred:Traceback (most recent call last): File "/tmp/python-nogil/lib/python3.14/site-packages/numpy/__init__.py", line 114, in <module> from numpy.__config__ import show as show_config File "/tmp/python-nogil/lib/python3.14/site-packages/numpy/__config__.py", line 4, in <module> from numpy._core._multiarray_umath import ( ...<3 lines>... ) File "/tmp/python-nogil/lib/python3.14/site-packages/numpy/_core/__init__.py", line 49, in <module> raise ImportError(msg)ImportError: IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!Importing the numpy C-extensions failed. This error can happen formany reasons, often due to issues with your setup or how NumPy wasinstalled.We have compiled some common reasons and troubleshooting tips at: https://numpy.org/devdocs/user/troubleshooting-importerror.htmlPlease note and check the following: * The Python version is: Python3.14 from "/tmp/python-nogil/bin/python3.14t" * The NumPy version is: "2.0.0"and make sure that they are the versions you expect.Please carefully study the documentation linked above for further help.Original error was: No module named 'numpy._core._multiarray_umath'The above exception was the direct cause of the following exception:Traceback (most recent call last): File "<string>", line 1, in <module> import numpy File "/tmp/python-nogil/lib/python3.14/site-packages/numpy/__init__.py", line 119, in <module> raise ImportError(msg) from eImportError: Error importing numpy: you should not try to import numpy from its source directory; please exit the numpy source tree, and relaunch your python interpreter from there.It would be better if installing NumPy in the default build did not make it available in the free-threaded build and vice versa.
Proposal
We should add the ABI suffix to the lib directory, like we do for the include directory. Specifically, we should usepython$(LDVERSION) instead ofpython$(VERSION).For example, the free-threaded build would uselib/python3.14t in Python 3.14.
Debug builds haved as part of their ABI suffix (and LDVERSION), so this would incidentally affect installations of the debug configuration of the non-free-threaded build.
Linked PRs
- gh-121103: Put free-threaded libraries in
lib/python3.14t#121293 - [3.13] gh-121103: Put free-threaded libraries in
lib/python3.14t(GH-121293) #121631 - gh-121103: Update site module docs for free-threaded installs #122737
- [3.13] gh-121103: Update site module docs for free-threaded installs (GH-122737) #122750
Metadata
Metadata
Assignees
Labels
Projects
Status