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' #143

Open
CharString opened this issue Mar 11, 2022 · 6 comments
Open

ModuleNotFoundError: No module named 'pkg_resources' #143

CharString opened this issue Mar 11, 2022 · 6 comments

Comments

@CharString
Copy link

We have a runtime dependency on setuptools:

import pkg_resources

but it's not named in the install_requires

circup/setup.py

Lines 25 to 34 in 86ff01c

install_requires = [
"semver~=2.13",
"Click>=8.0",
"appdirs>=1.4.3",
"requests>=2.22.0",
"findimports>=2.1.0",
# importlib_metadata is only available for 3.7, and is not needed for 3.8 and up.
"importlib_metadata; python_version == '3.7'",
"update_checker",
]

Alternatively we could migrate to importlib.resources (new in Python 3.7, but a backport for 3.6 exists)
https://docs.python.org/3/library/importlib.html#module-importlib.resources

@CharString
Copy link
Author

PS This is low priority since it isn't triggered if you use the recommended way of installing. I just bumped into it because I start projects using pdm:

$ pdm add circup
[…]
$ pdm run circup --help
Traceback (most recent call last):
  File "/home/chars/Projects/spukhaft/__pypackages__/3.7/bin/circup", line 5, in <module>
    from circup import main
  File "/home/chars/Projects/spukhaft/__pypackages__/3.7/lib/circup/__init__.py", line 23, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

@askpatrickw
Copy link
Contributor

@CharString, I'm not sure what PDM is, but please feel free to submit a PR and we're all happy to have a look at what the fix would be.

@putz612
Copy link

putz612 commented Oct 14, 2023

Just hit this one on a fresh install of Python 3.12 on Windows

PS C:\Users\user> circup list
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "C:\Users\jsievert\AppData\Local\Programs\Python\Python312\Scripts\circup.exe\__main__.py", line 4, in <module>
  File "C:\Users\jsievert\AppData\Local\Programs\Python\Python312\Lib\site-packages\circup\__init__.py", line 23, in <module>
    import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'

Running pip install setuptools fixes this issue

PS C:\Users\user> pip3 install setuptools
Collecting setuptools
  Obtaining dependency information for setuptools from https://files.pythonhosted.org/packages/bb/26/7945080113158354380a12ce26873dd6c1ebd88d47f5bc24e2c5bb38c16a/setuptools-68.2.2-py3-none-any.whl.metadata
  Using cached setuptools-68.2.2-py3-none-any.whl.metadata (6.3 kB)
Using cached setuptools-68.2.2-py3-none-any.whl (807 kB)
Installing collected packages: setuptools
Successfully installed setuptools-68.2.2

PS C:\Users\user> circup list
Found device at D:\, running CircuitPython 8.2.6.
Downloading latest version for adafruit/Adafruit_CircuitPython_Bundle.

It looks like its an undeclared runtime dependency that someone starting from scratch is going to hit. Can setuptools be added to the requirements?

@steka
Copy link

steka commented Nov 10, 2023

Running pip install setuptools fixes this issue

Thank you @putz612, that solved it for me too.

@dhalbert
Copy link
Contributor

See #143 for a generalization of the issue here.

@ajs256
Copy link

ajs256 commented May 30, 2024

I installed circup with pipx, as is recommended by pip when you're using a Homebrew Python, and needed to run pipx inject circup setuptools to get circup to work.

Just leaving this here for future readers.

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

6 participants