question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SystemError: Parent module 'setuptools' not loaded, cannot perform relative import with setuptools 50

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:53
  • Comments:23 (6 by maintainers)

github_iconTop GitHub Comments

14reactions
NicolasPAcommented, Aug 31, 2020

Same issue. Worked around with downgrading and blacklisting 50.0:

pip install "setuptools!=50.0" --force-reinstall

and in requirements.txt:

setuptools!=50.0
8reactions
jantmancommented, Sep 1, 2020

For what it’s worth:

  1. I’m not terribly new to Python, but the impact of “Once again, Setuptools overrides the stdlib distutils on import.” is completely lost on me, especially when it comes to discovering entrypoints.
  2. Whatever this “number of environments” is, by far the biggest impact to me is that my organization heavily uses Python (and setuptools entrypoints) inside of Docker images… and all of our images are based on Debian. I’d expect that many people/organizations are in this same situation (given the popularity of Debian as a base for Docker images) but may not have rebuilt images recently enough for the impact to be discovered.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Parent module 'setuptools' not loaded, cannot perform relative ...
SystemError : Parent module 'setuptools' not loaded, cannot perform relative import. Python - 3.5.2. How to resolve this?
Read more >
[Solved] SystemError Parent Module Not Loaded Cannot ...
Systemerror parent module not loaded cannot perform relative import is raised as code fails to relative import a module from another module.
Read more >
Django, python3, on install I get: "Parent module 'setuptools ...
_bootstrap>", line 931, in _sanity_check SystemError: Parent module 'setuptools' not loaded, cannot perform relative import
Read more >
T261748 Travis test 3.5_with_system_site_packages fails ...
_bootstrap>", line 931, in _sanity_check SystemError: Parent module 'setuptools' not loaded, cannot perform relative import ...
Read more >
Juniper Installation Failing - Site Operations Help
_bootstrap>\", line 931, in _sanity_check\nSystemError: Parent module 'setuptools' not loaded, cannot perform relative import", ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found