Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleNotFoundError: No module named 'pkg_resources' #1990

Open
ineesalmeida opened this issue Feb 11, 2020 · 5 comments
Open

ModuleNotFoundError: No module named 'pkg_resources' #1990

ineesalmeida opened this issue Feb 11, 2020 · 5 comments

Comments

@ineesalmeida
Copy link

ineesalmeida commented Feb 11, 2020

The docker environment where we run our tests has been failing since yesterday morning (10th February) with a ModuleNotFoundError: No module named 'pkg_resources' error.

After some investigation, we noticed it upgraded setuptools to version 45.2.0 on that morning.

Downgrading setuptools to 45.1.0 fixed our issue, and everything is working as expected again.

There might have been some change in 45.2.0 that triggered this issue. Let me know what other information I can provide.

Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 364, in execute_from_command_line
    utility.execute()
  File "/venv/lib/python3.6/site-packages/django/core/management/__init__.py", line 338, in execute
    django.setup()
  File "/venv/lib/python3.6/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/venv/lib/python3.6/site-packages/django/apps/registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "/venv/lib/python3.6/site-packages/django/apps/config.py", line 94, in create
    module = import_module(entry)
  File "/usr/local/lib/python3.6/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 994, in _gcd_import
  File "<frozen importlib._bootstrap>", line 971, in _find_and_load
  File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 678, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/venv/lib/python3.6/site-packages/nested_admin/__init__.py", line 10, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
@natsteinmetz
Copy link

I'm facing the same problem ☝️

@ineesalmeida
Copy link
Author

We found out that using the inbuilt venv instead of virtualenv (using setuptools 45.2.0) actually also worked

rhosqeauto pushed a commit to redhat-openstack/infrared that referenced this issue Feb 11, 2020
There are issues with imports with setuptools 45.2.0
so we make sure that we limit the one we use for the
shade venv to the last version prior.

[a] pypa/setuptools#1990

Change-Id: I5501109835db30d713d9a687d55befaf939db6a6
@jaraco
Copy link
Member

jaraco commented Mar 8, 2020

I'm unable to replicate your issue:

draft $ pip-run virtualenv -- -m virtualenv env                                                                                                                           
Collecting virtualenv
  Using cached virtualenv-20.0.9-py2.py3-none-any.whl (4.6 MB)
Collecting appdirs<2,>=1.4.3
  Using cached appdirs-1.4.3-py2.py3-none-any.whl (12 kB)
Collecting six<2,>=1.9.0
  Using cached six-1.14.0-py2.py3-none-any.whl (10 kB)
Processing /Users/jaraco/Library/Caches/pip/wheels/eb/4e/d2/a903d4184fb49e4ac06474d65715b129aee13d69f7d227e78e/distlib-0.3.0-py3-none-any.whl
Collecting filelock<4,>=3.0.0
  Using cached filelock-3.0.12-py3-none-any.whl (7.6 kB)
Installing collected packages: appdirs, six, distlib, filelock, virtualenv
Successfully installed appdirs-1.4.3 distlib-0.3.0 filelock-3.0.12 six-1.14.0 virtualenv-20.0.9
created virtual environment CPython3.8.1.final.0-64 in 287ms
  creator CPython3Posix(dest=/Users/jaraco/draft/env, clear=False, global=False)
  seeder FromAppData(download=False, pip=latest, setuptools=latest, wheel=latest, via=copy, app_data_dir=/Users/jaraco/Library/Application Support/virtualenv/seed-app-data/v1)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
draft $ env/bin/pip install setuptools==45.2.0                                                                                                                            
Collecting setuptools==45.2.0
  Using cached setuptools-45.2.0-py3-none-any.whl (584 kB)
Installing collected packages: setuptools
  Attempting uninstall: setuptools
    Found existing installation: setuptools 45.3.0
    Uninstalling setuptools-45.3.0:
      Successfully uninstalled setuptools-45.3.0
Successfully installed setuptools-45.2.0
draft $ env/bin/python -c "import pkg_resources"                                                                                                                          
(no output)

Can you perhaps put together a minimal Dockerfile that replicates the issue?

@alexscott-ff
Copy link

Was anyone able to figure this out? @ineesalmeida do you mind elaborating on your solution (if you remember... we're using Poetry so not sure if relevant). Seeing this as well.

@abravalheri
Copy link
Contributor

abravalheri commented Sep 2, 2022

Hi @alexscott-ff , could you please share with us a minimal reproducible example that demonstrates a (simplied) situation when this error happens (as mentioned by Jason)?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants