setuptools: SystemError: Parent module 'setuptools' not loaded, cannot perform relative import with setuptools 50
After upgrading setuptools to 50.0 today, the environment fails to locate the entry points as it could not import distutils
$ python --version
Python 3.5.1
$ python -c "import distutils"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "/home/gchan/tmp/setuptools-python-3.5/lib/python3.5/site-packages/_distutils_hack/__init__.py", line 82, in create_module
return importlib.import_module('._distutils', 'setuptools')
File "/home/gchan/tmp/setuptools-python-3.5/lib64/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 981, in _gcd_import
File "<frozen importlib._bootstrap>", line 931, in _sanity_check
SystemError: Parent module 'setuptools' not loaded, cannot perform relative import
The issue could not be found in the python 3.8 environment.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 53
- Comments: 23 (6 by maintainers)
Links to this issue
Commits related to this issue
- Pin setuptools to a version < 50.0 when installing pipenv Experiencing a problem where `pip install pipenv` yields: ``` SystemError: Parent module 'setuptools' not loaded, cannot perform relative im... — committed to freedomofpress/pressfreedomtracker.us by chigby 4 years ago
- Pin setuptools to a version < 50.0 when installing pipenv Experiencing a problem where `pip install pipenv` yields: ``` SystemError: Parent module 'setuptools' not loaded, cannot perform relative im... — committed to freedomofpress/pressfreedomtracker.us by chigby 4 years ago
- Pin setuptools to a version < 50.0 when installing pipenv Experiencing a problem where `pip install pipenv` yields: ``` SystemError: Parent module 'setuptools' not loaded, cannot perform relative im... — committed to freedomofpress/pressfreedomtracker.us by chigby 4 years ago
- Pin setuptools to a version < 50.0 when installing pipenv Experiencing a problem where `pip install pipenv` yields: ``` SystemError: Parent module 'setuptools' not loaded, cannot perform relative im... — committed to freedomofpress/pressfreedomtracker.us by chigby 4 years ago
- Pin setuptools to a version < 50.0 when installing pipenv Experiencing a problem where `pip install pipenv` yields: ``` SystemError: Parent module 'setuptools' not loaded, cannot perform relative im... — committed to freedomofpress/pressfreedomtracker.us by chigby 4 years ago
- Blacklist setuptool version 50.0 to fix kokoro Context: https://github.com/pypa/setuptools/issues/2352 PiperOrigin-RevId: 329312581 — committed to tensorflow/datasets by Conchylicultor 4 years ago
- Blacklist setuptool version 50.0 to fix kokoro Context: https://github.com/pypa/setuptools/issues/2352 PiperOrigin-RevId: 329312581 — committed to tensorflow/datasets by Conchylicultor 4 years ago
- BF: work round setuptools 50.0 bug See https://github.com/pypa/setuptools/issues/2352 and https://github.com/pypa/setuptools/blob/17cb9d6bf249cefe653d3bdb712582409035a7db/CHANGES.rst#v5000 — committed to resampling-stats/resampling-with by matthew-brett 4 years ago
- Blacklist setuptool version 50.0 to fix kokoro Context: https://github.com/pypa/setuptools/issues/2352 PiperOrigin-RevId: 329312581 — committed to tensorflow/datasets by Conchylicultor 4 years ago
- Pin setuptools<50 in our image venvs setuptools==50 doesn't work with python older than python3.8. There are a number of issues [0][1][2] the first of which we are tripping over. Be conservative here... — committed to openstack/project-config by cboylan 4 years ago
- Workaround https://github.com/pypa/setuptools/issues/2352 — committed to leezu/mxnet by leezu 4 years ago
- Workaround https://github.com/pypa/setuptools/issues/2352 — committed to leezu/mxnet by leezu 4 years ago
- ci: pip, blacklist setuptools version 50.0 see: https://github.com/pypa/setuptools/issues/2352 — committed to FreyJo/acados by FreyJo 4 years ago
- ci: pip, blacklist setuptools version 50.0 see: https://github.com/pypa/setuptools/issues/2352 — committed to acados/acados by FreyJo 4 years ago
- 1.x: Stop packaging GPL libquadmath.so (#19055) * Stop packaging GPL libquadmath.so (#19053) libquadmath.so is GPL and must not be distributed by Apache projects. Users will need to ensure that li... — committed to apache/mxnet by leezu 4 years ago
- Don't install setuptools >= 50.0.0 until they release something useful https://github.com/pypa/setuptools/issues/2352#issuecomment-685046897 — committed to s0undt3ch/salt by s0undt3ch 4 years ago
- fix setuptool import issue https://github.com/pypa/setuptools/issues/2352 — committed to ChaiBapchya/mxnet by ChaiBapchya 4 years ago
- Add temporary "escape hatch" envvar for setuptools v50.0.0 Without this workaround we just started receiving the following error during build now. ``` Traceback (most recent call last): File "mana... — committed to ministryofjustice/laa-fee-calculator by jsugarman 4 years ago
- Blacklist setuptools 50.0 while the build is not fixed https://github.com/pypa/setuptools/issues/2352 — committed to eol-uchile/edx-staging by fdns 4 years ago
- Merge #196 196: Blacklist setuptools 50.0 while the build is not fixed r=fdns a=fdns https://github.com/pypa/setuptools/issues/2352 bors r+ Co-authored-by: Felipe Espinoza <fdns@users.noreply.gi... — committed to eol-uchile/edx-staging by bors[bot] 4 years ago
Same issue. Worked around with downgrading and blacklisting 50.0:
and in
requirements.txt
:For what it’s worth:
Can anyone clarify what
SETUPTOOLS_USE_DISTUTILS=stdlib
actually does? I realize it’s a workaround, and it’s definitely necessary right now for many of us, but how different is it from pre-50 behavior, if at all?The workaround described in the changelog worked for me:
The environment variable is explained in the changelog, along with the change that caused the breakage: https://setuptools.readthedocs.io/en/latest/history.html#v50-0-0 . But I think the number of “environments or invocations where this behavior is undesirable” was far larger than expected, being basically anybody on Debian, Ubuntu, or any other Debian-derived distribution.
On my side the impact is significant as every environments (by default installed by the latest setuptools) breaks. Many dependencies / libraries directly import distutils for the LooseVersion class. We cannot ask the downstream users to inject the environment variable always as well. I think eventually we should accept that setuptools monkeypatch distutils internally. But I just do not understand
Why does it occur on older Python 3 versions, e.g. python 3.5 and 3.6?
Why does setuptools hack the stdlib distutils even when other packages import distutils directly?
@jmbowman I read it, but I am concerned about the phrase “temporary escape hatch”… this is turning out to be a significant change that’ll have a broad negative impact (especially, as @jantman notes, it will impact many who don’t regularly rebuild their images and will run into this in the coming days and weeks). The thought that this will soon become impossible to override is worrisome - some reassurance that this won’t be so temporary an escape hatch would be appreciated.
I’d be happy just to pin down to < 50.0 in the requirements until this no longer breaks things, but that’s highly discouraged when it comes to a requirements-based install. I’m not sure there’s any other viable workaround except for the escape hatch above.
(FWIW I’m @MartyMacGyver above so this is part of the same thread)