poetry
poetry copied to clipboard
When there is a conflict between the Python version and the package, error messages can be confusing.
- [x ] I have searched the issues of this repo and believe that this is not a duplicate.
- [ x] I have searched the FAQ and general documentation and believe that my question is not already covered.
When there is a conflict between the Python version and the package, error messages can be confusing.
when I try to install numpy1.25.2 using poetry with python3.12, it will show error message like this:
• Installing numpy (1.25.2): Failed
ChefBuildError
Backend 'setuptools.build_meta:__legacy__' is not available.
Traceback (most recent call last):
File "/opt/homebrew/Cellar/poetry/1.7.1/libexec/lib/python3.12/site-packages/pyproject_hooks/_in_process/_in_process.py", line 77, in _build_backend
obj = import_module(mod_path)
^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/homebrew/Cellar/[email protected]/3.12.1_1/Frameworks/Python.framework/Versions/3.12/lib/python3.12/importlib/__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 994, in exec_module
File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
File "/private/var/folders/sk/ldq44t9j7735_tpmvr3hzjh80000gn/T/tmp0z5pdhdq/.venv/lib/python3.12/site-packages/setuptools/__init__.py", line 10, in <module>
import distutils.core
ModuleNotFoundError: No module named 'distutils'
at /opt/homebrew/Cellar/poetry/1.7.1/libexec/lib/python3.12/site-packages/poetry/installation/chef.py:164 in _prepare
160│
161│ error = ChefBuildError("\n\n".join(message_parts))
162│
163│ if error is not None:
→ 164│ raise error from None
165│
166│ return path
167│
168│ def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path:
Note: This error originates from the build backend, and is likely not a problem with poetry but with numpy (1.25.2) not supporting PEP 517 builds. You can verify this by running 'pip wheel --no-cache-dir --use-pep517 "numpy (==1.25.2)"'.
The real issue lies in Python 3.12 dropping distutils, causing compatibility issues with numpy 1.25.2. Unfortunately, the error message can be quite confusing, especially for newcomers. Can we work on providing clearer and more helpful error guidance?
If you have a suggested improvement please submit a merge request
There are no 3.12 wheels for that version of numpy, i strongly encourage you to use a version of numpy that has pre built wheels, like 1.26.3.
While I can understand the error itself can be a bit overwhelming for someone new to Python, I agree with the above commits that if there is a recommendation for this please raise a pull request.
The error is probably the best we can do because Poetry cannot guess situations like "numpy 1.25.2 does not support building wheels under 3.12" since there is no explicit mention of python>=3.0.0, <3.12.0
in the package metadata outside of "supported python versions" via classifiers. And we cannot know which project builds fail because of distutils
being not present.
For what it is worth, the error is correct in that the issue here is that numpy=1.25.2
does not support a PEP 517 build under your environment. If we start trying to handle every such case in error handling, it is a rather bug effort.
Closing for now, but if anyone really wants an improvement here please open a pull request with a suggestion.
@Dragonchu thank you for taking the time to report this, it is definitely appreciated.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.