You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SystemError: Parent module 'setuptools' not loaded, cannot perform relative import with setuptools 50 #2352
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.
Same here, Ubuntu 16.04. Seems to be another symptom of #2350.
SystemError: Parent module 'setuptools' not loaded, cannot perform relative import
File "<frozen importlib._bootstrap>", line 931, in _sanity_check
File "<frozen importlib._bootstrap>", line 981, in _gcd_import
return _bootstrap._gcd_import(name[level:], package, level)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return importlib.import_module('._distutils', 'setuptools')
File "/usr/local/lib/python3.5/dist-packages/_distutils_hack/__init__.py", line 82, in create_module
File "<frozen importlib._bootstrap>", line 577, in module_from_spec
File "<frozen importlib._bootstrap>", line 666, in _load_unlocked
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
from distutils.version import StrictVersion
File "/usr/local/lib/python3.5/dist-packages/redis/connection.py", line 2, in <module>
from redis.connection import (ConnectionPool, UnixDomainSocketConnection,
File "/usr/local/lib/python3.5/dist-packages/redis/client.py", line 12, in <module>
from redis.client import Redis, StrictRedis
File "/usr/local/lib/python3.5/dist-packages/redis/__init__.py", line 1, in <module>
from redis import Redis
[...]
Same issue.
Worked around with downgrading and blacklisting 50.0:
pipinstall"setuptools!=50.0"--force-reinstall
and in requirements.txt:
setuptools!=50.0
Reacted by Kennedy Mwenja, Jorrick Sleijster, Athul Muralidhar, Oren Rozen, Damien Gustave, ivan petrushenko, Mike Klebolt, Christoph Lingg, shacharCfir, Conchylicultor and 4 more
❯ pipenv
Traceback (most recent call last):
File "/home/apinio/.local/bin/pipenv", line 5, in <module>
from pipenv import cli
File "/home/apinio/.local/lib/python3.5/site-packages/pipenv/__init__.py", line 55, in <module>
from .cli import cli
File "/home/apinio/.local/lib/python3.5/site-packages/pipenv/cli/__init__.py", line 4, in <module>
from .command import cli # noqa
File "/home/apinio/.local/lib/python3.5/site-packages/pipenv/cli/command.py", line 15, in <module>
from .options import (
File "/home/apinio/.local/lib/python3.5/site-packages/pipenv/cli/options.py", line 14, in <module>
from ..utils import is_valid_url
File "/home/apinio/.local/lib/python3.5/site-packages/pipenv/utils.py", line 16, in <module>
from distutils.spawn import find_executable
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/apinio/.local/lib/python3.5/site-packages/_distutils_hack/__init__.py", line 82, in create_module
return importlib.import_module('._distutils', 'setuptools')
File "/usr/lib/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
Downgrading to setuptools-49.6.0 fixes the problem.
@MartinFalatic - Can you share a log/traceback? The particular exception in the original issue report was removed in Python 3.6.3 RC1+ as part of the fix for https://bugs.python.org/issue30876.
[14:34:24][Docker Compose Build] Step 5/18 : RUN DJANGO_SECRET_KEY=redacted ENABLE_DEBUG=1 python3 manage.py collectstatic --noinput --clear
[14:34:24][Docker Compose Build] ---> Running in 97410cbaf12e
[14:34:25][Docker Compose Build] Traceback (most recent call last):
[14:34:25][Docker Compose Build] File "manage.py", line 18, in <module>
[14:34:25][Docker Compose Build] execute_from_command_line(sys.argv)
[14:34:25][Docker Compose Build] File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
[14:34:25][Docker Compose Build] utility.execute()
[14:34:25][Docker Compose Build] File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 357, in execute
[14:34:25][Docker Compose Build] django.setup()
[14:34:25][Docker Compose Build] File "/usr/local/lib/python3.6/dist-packages/django/__init__.py", line 24, in setup
[14:34:25][Docker Compose Build] apps.populate(settings.INSTALLED_APPS)
[14:34:25][Docker Compose Build] File "/usr/local/lib/python3.6/dist-packages/django/apps/registry.py", line 91, in populate
[14:34:25][Docker Compose Build] app_config = AppConfig.create(entry)
[14:34:25][Docker Compose Build] File "/usr/local/lib/python3.6/dist-packages/django/apps/config.py", line 90, in create
[14:34:25][Docker Compose Build] module = import_module(entry)
[14:34:25][Docker Compose Build] File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
[14:34:25][Docker Compose Build] return _bootstrap._gcd_import(name[level:], package, level)
[14:34:25][Docker Compose Build] File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[14:34:25][Docker Compose Build] File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[14:34:25][Docker Compose Build] File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
[14:34:25][Docker Compose Build] ModuleNotFoundError: No module named 'dal'
[14:34:25][Docker Compose Build] Service 'nginx' failed to build: The command '/bin/sh -c DJANGO_SECRET_KEY=redacted ENABLE_DEBUG=1 python3 manage.py collectstatic --noinput --clear' returned a non-zero code: 1
Using setuptools 50.0.2 without workaround:
[15:50:39][Docker Compose Build] Step 5/18 : RUN DJANGO_SECRET_KEY=redacted ENABLE_DEBUG=1 python3 manage.py collectstatic --noinput --clear
[15:50:39][Docker Compose Build] ---> Running in 49057705f89d
[15:50:40][Docker Compose Build] Traceback (most recent call last):
[15:50:40][Docker Compose Build] File "manage.py", line 18, in <module>
[15:50:40][Docker Compose Build] execute_from_command_line(sys.argv)
[15:50:40][Docker Compose Build] File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
[15:50:40][Docker Compose Build] utility.execute()
[15:50:40][Docker Compose Build] File "/usr/local/lib/python3.6/dist-packages/django/core/management/__init__.py", line 357, in execute
[15:50:40][Docker Compose Build] django.setup()
[15:50:40][Docker Compose Build] File "/usr/local/lib/python3.6/dist-packages/django/__init__.py", line 24, in setup
[15:50:40][Docker Compose Build] apps.populate(settings.INSTALLED_APPS)
[15:50:40][Docker Compose Build] File "/usr/local/lib/python3.6/dist-packages/django/apps/registry.py", line 91, in populate
[15:50:40][Docker Compose Build] app_config = AppConfig.create(entry)
[15:50:40][Docker Compose Build] File "/usr/local/lib/python3.6/dist-packages/django/apps/config.py", line 90, in create
[15:50:40][Docker Compose Build] module = import_module(entry)
[15:50:40][Docker Compose Build] File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
[15:50:40][Docker Compose Build] return _bootstrap._gcd_import(name[level:], package, level)
[15:50:40][Docker Compose Build] File "<frozen importlib._bootstrap>", line 994, in _gcd_import
[15:50:40][Docker Compose Build] File "<frozen importlib._bootstrap>", line 971, in _find_and_load
[15:50:40][Docker Compose Build] File "<frozen importlib._bootstrap>", line 953, in _find_and_load_unlocked
[15:50:40][Docker Compose Build] ModuleNotFoundError: No module named 'dal'
[15:50:40][Docker Compose Build] Service 'nginx' failed to build: The command '/bin/sh -c DJANGO_SECRET_KEY=redacted ENABLE_DEBUG=1 python3 manage.py collectstatic --noinput --clear' returned a non-zero code: 1
Those appear to be identical.
The following does get mentioned in the log during the main pip3 install part of the build (with and without the workaround). I mention it only for completeness as this problem is certainly affected by the setuptools version being >= 50. Note that setuptools is NOT being pinned in the requirements (as that would be problematic).
[15:48:20][Docker Compose Build] Found existing installation: setuptools 39.0.1
[15:48:20][Docker Compose Build] Not uninstalling setuptools at /usr/lib/python3/dist-packages, outside environment /usr
Activity
aaronlee-xyz commentedon Aug 31, 2020
Found the same issue with python 3.6.1 (pyenv)
akx commentedon Aug 31, 2020
Same here, Ubuntu 16.04. Seems to be another symptom of #2350.
ThomasDevoogdt commentedon Aug 31, 2020
The same can be said for Matplotlib:
NicolasPA commentedon Aug 31, 2020
Same issue.
Worked around with downgrading and blacklisting 50.0:
and in
requirements.txt:Pin setuptools to a version < 50.0 when installing pipenv
Pin setuptools to a version < 50.0 when installing pipenv
Pin setuptools to a version < 50.0 when installing pipenv
Pin setuptools to a version < 50.0 when installing pipenv
Pin setuptools to a version < 50.0 when installing pipenv
Blacklist setuptool version 50.0 to fix kokoro
Blacklist setuptool version 50.0 to fix kokoro
dwrensha commentedon Aug 31, 2020
The workaround described in the changelog worked for me:
alepinio commentedon Aug 31, 2020
Same issue here with python 3.5.2,
Downgrading to
setuptools-49.6.0fixes the problem.BF: work round setuptools 50.0 bug
Blacklist setuptool version 50.0 to fix kokoro
30 remaining items
Adjust setuptools installation to workaround upstream changes
MartinFalatic commentedon Sep 1, 2020
Is this change, as implemented in 50.0.2, supposed to eliminate the need for the
SETUPTOOLS_USE_DISTUTILS=stdlibworkaround?If so, it is not working out that way. Seeing the same problem as before (without the workaround) and the build is picking up 50.0.2
Ubuntu 18.04 with
python3 (3.6.7-1~18.04)in DockerFixed windows python3.6 issue.
cicconej commentedon Sep 2, 2020
@MartinFalatic - Can you share a log/traceback? The particular exception in the original issue report was removed in Python 3.6.3 RC1+ as part of the fix for https://bugs.python.org/issue30876.
Note the absence of https://github.com/python/cpython/blob/v3.6.2/Lib/importlib/_bootstrap.py#L920-L923 in https://github.com/python/cpython/blob/v3.6.7/Lib/importlib/_bootstrap.py#L917-L930.
MartinFalatic commentedon Sep 2, 2020
Using setuptools 50.0.0 without workaround:
Using setuptools 50.0.2 without workaround:
Those appear to be identical.
The following does get mentioned in the log during the main pip3 install part of the build (with and without the workaround). I mention it only for completeness as this problem is certainly affected by the setuptools version being >= 50. Note that setuptools is NOT being pinned in the requirements (as that would be problematic).
Also, 'dal' = django-autocomplete-light.
MartinFalatic commentedon Sep 2, 2020
It's worth noting that this was closed as duplicate when I brought it up here... #2356 (comment)
Similar but perhaps not quite the same problem after all, perhaps.
Blacklist setuptool version 50.0 to fix kokoro
Force docker-compose build to upgrade setuptools
[DOC][v1.7.x] Fix pip cu102link (#19054)
Fix CI by avoiding setuptools 50.0
Remove workaround for setuptools issue
Remove workaround for setuptools issue
Remove workaround for setuptools issue
remove pinned setuptools
remove pinned setuptools (#463)