poetry: 1.0.10 -> 1.1 regression: EnvCommandError: 'No module named setuptools' on Python 3.7
This may because it’s installing a nested package. Python 3.8 doesn’t have this issue but 3.7 does. I don’t have a reduced test case yet. I’m hoping the traceback is helpful and someone knows what’s going on from it. Python 3.7 and 3.8 are fine with Poetry 1.0.10, everything else being identical. Python 3.8 with Poetry 1.1.2 is fine as well, just not Python 3.7 with Poetry 1.1.2.
EnvCommandError
Command ['/usr/local/bin/python', '-m', 'pip', 'install', '--no-deps', '-U', '/builds/[redacted]'] errored with the following return code 2, and output:
Looking in indexes: https://[redacted]
Processing ./packages/[redacted]
Installing build dependencies: started
Installing build dependencies: finished with status 'done'
Getting requirements to build wheel: started
Getting requirements to build wheel: finished with status 'done'
ERROR: Exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/base_command.py", line 216, in _main
status = self.run(options, args)
File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 182, in wrapper
return func(self, options, args)
File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 325, in run
reqs, check_supported_wheels=not options.target_dir
File "/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 183, in resolve
discovered_reqs.extend(self._resolve_one(requirement_set, req))
File "/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 388, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/usr/local/lib/python3.7/site-packages/pip/_internal/resolution/legacy/resolver.py", line 340, in _get_abstract_dist_for
abstract_dist = self.preparer.prepare_linked_requirement(req)
File "/usr/local/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 483, in prepare_linked_requirement
req, self.req_tracker, self.finder, self.build_isolation,
File "/usr/local/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 91, in _get_prepared_distribution
abstract_dist.prepare_distribution_metadata(finder, build_isolation)
File "/usr/local/lib/python3.7/site-packages/pip/_internal/distributions/sdist.py", line 38, in prepare_distribution_metadata
self._setup_isolation(finder)
File "/usr/local/lib/python3.7/site-packages/pip/_internal/distributions/sdist.py", line 96, in _setup_isolation
reqs = backend.get_requires_for_build_wheel()
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/wrappers.py", line 161, in get_requires_for_build_wheel
'config_settings': config_settings
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/wrappers.py", line 265, in _call_hook
raise BackendUnavailable(data.get('traceback', ''))
pip._vendor.pep517.wrappers.BackendUnavailable: Traceback (most recent call last):
File "/usr/local/lib/python3.7/site-packages/pip/_vendor/pep517/_in_process.py", line 86, in _build_backend
obj = import_module(mod_path)
File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/tmp/pip-build-env-l4t_85ci/overlay/lib/python3.7/site-packages/poetry/masonry/api.py", line 1, in <module>
from poetry.core.masonry.api import build_sdist
File "/tmp/pip-build-env-l4t_85ci/overlay/lib/python3.7/site-packages/poetry/core/masonry/__init__.py", line 10, in <module>
from .builder import Builder
File "/tmp/pip-build-env-l4t_85ci/overlay/lib/python3.7/site-packages/poetry/core/masonry/builder.py", line 6, in <module>
from .builders.sdist import SdistBuilder
File "/tmp/pip-build-env-l4t_85ci/overlay/lib/python3.7/site-packages/poetry/core/masonry/builders/__init__.py", line 2, in <module>
from .wheel import WheelBuilder
File "/tmp/pip-build-env-l4t_85ci/overlay/lib/python3.7/site-packages/poetry/core/masonry/builders/wheel.py", line 18, in <module>
from packaging.tags import sys_tags
File "/tmp/pip-build-env-l4t_85ci/overlay/lib/python3.7/site-packages/poetry/core/_vendor/packaging/tags.py", line 7, in <module>
import distutils.util
File "/usr/local/lib/python3.7/site-packages/_distutils_hack/__init__.py", line 83, in create_module
return importlib.import_module('._distutils', 'setuptools')
File "/usr/local/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
ModuleNotFoundError: No module named 'setuptools'
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 18
- Comments: 42 (19 by maintainers)
Commits related to this issue
- Test workaround from python-poetry/poetry#3153 — committed to abey79/vpype by abey79 4 years ago
- Workaround suggested at https://github.com/python-poetry/poetry/issues/3153#issuecomment-727196619 — committed to jwg4/exact_cover by jwg4 3 years ago
- Work around poetry 1.1 regression See https://github.com/python-poetry/poetry/issues/3153#issuecomment-758302596 for more information. — committed to TheAssassin/pyuploadtool by TheAssassin 3 years ago
- Pin poetry version Workaround for https://github.com/python-poetry/poetry/issues/3153. — committed to TheAssassin/pyuploadtool by TheAssassin 3 years ago
- Workaround for Poetry 1.1 See https://github.com/python-poetry/poetry/issues/3153#issuecomment-758302596 — committed to scikit-learn-contrib/sklearn-ann by frankier 3 years ago
- - Added "setuptools" in the [build-system] requires as an workaround for https://github.com/python-poetry/poetry/issues/3153. - Changed the SeldonMessage and Feedback as an workaround for https://gith... — committed to fernandocamargoai/bento2seldon by fernandocamargoai 3 years ago
- Pin poetry version Workaround for https://github.com/python-poetry/poetry/issues/3153. — committed to srevinsaju/pyuploadtool by TheAssassin 3 years ago
- Fix running `pip install .` in a source checkout corrscope uses poetry, while pip expects a setuptools project and will create package name UNKNOWN if run without setup.py or pyproject.toml [build-sy... — committed to corrscope/corrscope by nyanpasu64 3 years ago
- Fix running `pip install .` in a source checkout (#385) corrscope uses poetry, while pip expects a setuptools project and will create package name UNKNOWN if run without setup.py or pyproject.toml ... — committed to corrscope/corrscope by nyanpasu64 3 years ago
- Fixing install error on JupyterLab Based on https://github.com/python-poetry/poetry/issues/3153#issuecomment-727196619 — committed to HCDigitalScholarship/intervals by apjanco 2 years ago
- feat: add changelog / release notes support pyuploadtool now generates changelog for GitHub releases which is opt-in. Changelogs will be generated only when GENERATE_CHANGELOG=true feat: prepend th... — committed to srevinsaju/pyuploadtool by srevinsaju 4 years ago
- feat: add changelog / release notes support pyuploadtool now generates changelog for GitHub releases which is opt-in. Changelogs will be generated only when GENERATE_CHANGELOG=true feat: prepend th... — committed to srevinsaju/pyuploadtool by srevinsaju 4 years ago
- feat: add changelog / release notes support pyuploadtool now generates changelog for GitHub releases which is opt-in. Changelogs will be generated only when GENERATE_CHANGELOG=true feat: prepend th... — committed to TheAssassin/pyuploadtool by srevinsaju 4 years ago
In https://github.com/python-poetry/poetry/issues/1135#issuecomment-719902456 @NeilGirdhar pointed out that one would need to change pyproject.toml to include setuptools:
With this added in my above example (reproduce-3153.zip) it now builds:
And indeed, as others have mentioned in https://github.com/python-poetry/poetry/issues/34, this is not a
poetry
issue. But it seems like many would likepoetry
to have a workaround.same issue, wrapt depends on it, manually removing setuptools from the poetry.lock worked for me
This still happens on a fresh install of Poetry (1.1.13) with Python 3.10.2 (on Arch Linux, at least). I tried to follow the
poetry-demo
tutorial but it exploded when I attempted:Adding
setuptools
to the[build-system]
section doesn’t fix it. Note that I’m using the system-provided versions ofpip
(20.3.4) andsetuptools
(59.3.0), although the virtualenv seems to be pulling it’s own version ofpip
anyway (21.3.1).Update: Actually the problem may be with
pendulum
itself. I was just able to do apoetry add more-itertools
without issue.For folks facing this issue, can you please try master? Note that you will need to use a new virtual environment or run
poetry install --remove-untracked
on existing environments.Using pipx
Using a container (podman | docker)
I can confirm this is a problem and affects anything that ultimately still depends on calling
python setup.py
, such as:pip install -e
pyproject.toml
like @jonapich demonstrates withtest-testing = { path = "../test-testing/" }
I can confirm the problem with Python 3.6, 3.7 and 3.8 alike.
And this is really hard to debug because even if you literally copy and paste the command it’s trying to run, it just works, in my case for a sample package:
But if I simply copy and paste the command below, it runs ok:
To make this “work” I had to install bogus
setup.py
files to my packages, such as:Yet it still fails when running from within poetry.
@abn good point. Apparently I have
1.2.0a
installed for some reason. Thanks for pointing that out! Downgrading to 1.1.11 fixes the problem.I’m seeing this in Github Actions now (example: https://github.com/jrnl-org/jrnl/runs/3016985092). Has anyone found a workaround?
Also, I noticed that the first line after running
poetry install
is:And this still happens even if I remove the
--remove-untracked
flag. Interestingly, though, this error isn’t happening when I install poetry v1.2.0a1. So maybe it’s already fixed somehow?Some things I tried:
setuptools
(said it was already installed)--remove-untracked
flag (still see the “removing setuptools” line)Here are a bunch of CI runs that show the issue, in case it helps:
Hi, if I understood the status of this issue correctly, a workaround (for the obscure setuptools problem, which will not go away until poetry no longer uses setuptools) is on main, but not released yet, and for a package which is built by poetry, but which has a setup.py (for example, setup.py which is used to install the sdist), one can workaround until the next release, by adding
as suggested by @kbakk. Is this correct?
I don’t understand completely what’s going on here. But the root cause seems to be, that
setuptools
started to vendordistutils
in a way, that whenever a module importsdistutils
it gets redirected to the vendored version ofsetuptools
. And that seems not work in any case. See https://github.com/pypa/distutils/issues/17So the problem is not, that
setuptools
is not installed. The problem is, that the version ofsetuptools
that comes with the isolated build environment doesn’t work as expected. A workaround is to runexport SETUPTOOLS_USE_DISTUTILS=stdlib
before apip install
.So at it stands now, it looks to me a
setuptools
problem and not apoetry
problem.I went through the trouble of removing everything python and poetry off my system. I then reinstalled py3.8 using the latest installer and then reinstalled poetry using the Invoke-Webrequest method from the docs.
The behavior is still the same. Some observations:
poetry run python -m pip list
I can see setuptools is installed in the project’s virtual environment.poetry run python
I canimport distutils.util
This is where poetry breaks it for me even though python/pip can handle it:
poetry shell
and then proceed topip install ../test-testing/
it will fail.python -m venv virtualenv
and then callvirtualenv/Scripts/pip install ../test-testing/
it works.Additional note: The dependencies in
test-testing
have no effect on the issue. I tried to remove them all but I’m still unable to install it ifpoetry
is involved with it.I am also getting this error and I can reproduce it.
https://github.com/jonapich/test-poetry-setuptools
Clone that repo, and try “poetry install” in the test-functools folder, you will get the same stacktrace as in the bug report.
This seems pretty serious 🤔
I’m on 1.1.3, Windows, using powershell. I installed using the get-poetry bootstrap.
I have confirmed that this bug appears when going from 1.0.10 -> 1.1 and it was also working in 1.0.9
Also, I never used python 3.7; only 3.6 and 3.8.
I ran into this issue with Poetry 1.2.0a2 as it adds
setuptools
to the lock file when 1.1.x would not. Relocking the project with 1.1.8 removes the setuptools dependency and resolves my issue.@jtzero yes after removing
setuptools
inpoetry.lock
its working now. Thank you.!!!i am also getting same issue even with this setup
I can’t reproduce this now. I’ll close it out unless someone else runs into it on 1.1.4.
@jonapich based on your description I have attempted to recreate the scenario (minus the windows environment). Let me know what needs to be changed to reproduce the issue.
Console Output