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.extern' #185

Closed
woky opened this issue Sep 24, 2019 · 7 comments
Closed

ModuleNotFoundError: No module named 'pkg_resources.extern' #185

woky opened this issue Sep 24, 2019 · 7 comments

Comments

@woky
Copy link

woky commented Sep 24, 2019

I was trying to install https://github.com/pypa/pipenv master branch, which depends on https://github.com/sarugaku/requirementslib (though it has its copy in vendor/ directory for some reason), and when run it fails with:

% pipenv
Traceback (most recent call last):
[...SNIPPED...]
  File "/usr/lib/python3.7/site-packages/pipenv/project.py", line 30, in <module>
    from .vendor.requirementslib.models.utils import get_default_pyproject_backend
  File "/usr/lib/python3.7/site-packages/pipenv/vendor/requirementslib/__init__.py", line 9, in <module>
    from .models.lockfile import Lockfile
  File "/usr/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/lockfile.py", line 15, in <module>
    from .requirements import Requirement
  File "/usr/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/requirements.py", line 49, in <module>
    from .setup_info import (
  File "/usr/lib/python3.7/site-packages/pipenv/vendor/requirementslib/models/setup_info.py", line 19, in <module>
    import pkg_resources.extern.packaging.requirements as pkg_resources_requirements
ModuleNotFoundError: No module named 'pkg_resources.extern'

I don't understand the concept but apparently pkg_resources.extern is broken:

And so in ArchLinux package of https://github.com/pypa/setuptools they simply removed the extern functionality: https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/python-setuptools&id=001edbba7669215db7c853ca4fc8b35f09f044f8#n26

  rm -r setuptools-$pkgver/{pkg_resources,setuptools}/{extern,_vendor}

  # Upstream devendoring logic is badly broken, see:
  # https://bugs.archlinux.org/task/58670
  # https://github.com/pypa/pip/issues/5429
  # https://github.com/pypa/setuptools/issues/1383
  # The simplest fix is to simply rewrite import paths to use the canonical
  # location in the first place

Can this library be changed to not depend on pkg_resources.extend? Apparently it's broken for some time and according to the comment above, its use can be replaced with canonical import paths.

@uranusjr
Copy link
Member

Are you sudo pip install-ing Pipenv globally? Don’t do that, Pipenv’s (and requirementslib) usage of pkg_resources tends to interact badly with system-supplied Python installation. If you wan to pip install Pipenv, use a virtual environment (and symlink bin/pipenv into PATH) instead.

@frostming
Copy link
Member

I would recommend https://github.com/pipxproject/pipx

pipx install pipenv

@ilai-deutel
Copy link

This issue breaks the python-pipenv-git package on the Arch Linux User Repository.
This package is supposed to provide a pipenv binary available system-wide. Arch Linux python packages are always installed globally (in /usr/lib/python3.7/site-packages) and rely on the system-supplied Python without using virtual environments.

@uranusjr
Copy link
Member

I would suggest raising this to maintainers of that package instead (either the upstream source the of Arch packager, if those two are different). They would be in a much better position to investigate and suggest a more informed solution.

@woky
Copy link
Author

woky commented Sep 27, 2019

Are you sudo pip install-ing Pipenv globally? Don’t do that

I don't pip install at all. I'm just running setup.py.

@woky
Copy link
Author

woky commented Sep 27, 2019

I would suggest raising this to maintainers of that package instead (either the upstream source the of Arch packager, if those two are different). They would be in a much better position to investigate and suggest a more informed solution.

Well, the pkg_resources.extern is apparently broken, proof being the still open issues in pip and setuptools. If maintainers bring it back to make packages that rely on it work, then it'll cause other breakages (described in the issues linked in the first post). As suggested, this mechanism doesn't have to be used, you can just import canonical paths.

@uranusjr
Copy link
Member

pkg_resources is part of Setuptools, not maintained by requirementslib. Since setuptools is a part of the default Python installation, it should be present by default. The usual suspect is platform-distributed Python, who like to strip parts of Python (because they don’t encourage people to use either pip install or setup.py against those Python distributions).

techalchemy added a commit that referenced this issue Mar 31, 2020
- Fixes #185

Signed-off-by: Dan Ryan <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants