jjjake / internetarchive

A Python and Command-Line Interface to Archive.org
GNU Affero General Public License v3.0
1.61k stars 218 forks source link

[Bug] No module named 'pkg_resources' #613

Closed ego-lay-atman-bay closed 7 months ago

ego-lay-atman-bay commented 1 year ago

I just installed this package in python 3.12 by running

pip install internet archive

It was able to install just fine, but when I ran ia, it threw this error

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:\Python\Python312\Scripts\ia.exe\__main__.py", line 4, in <module>
  File "C:\Python\Python312\Lib\site-packages\internetarchive\cli\__init__.py", line 26, in <module>
    from internetarchive.cli import (
  File "C:\Python\Python312\Lib\site-packages\internetarchive\cli\ia.py", line 67, in <module>
    from pkg_resources import DistributionNotFound, iter_entry_points
ModuleNotFoundError: No module named 'pkg_resources'

I downloaded the repo, and opened it in vscode. After I installed the pex-requirements.txt, vscode said that pkg_resources was found.

I think this might be a problem with python 3.12, because I was able to get it installed and working just fine with python 3.11.

jjjake commented 1 year ago

Thanks for the report @ego-lay-atman-bay. I am able to replicate this. Does this fix it for you (it did for me)?:

pip install setuptools

I'll look into this, thanks again for the report.

clydecbrown commented 10 months ago

pip install setuptools

This fixed it for me.

macOS 12.7.1 Homebrew Python 3.12.1 internetarchive 3.6.0

ego-lay-atman-bay commented 10 months ago

Oh yeah, that worked for me too. Should this stay open for other people who run into this issue?

JustAnotherArchivist commented 10 months ago

Python packaging has changed (read: improved) a fair bit in the past few years. setuptools used to be the one and only way to do anything with packages. That's not the case anymore. Packages can be installed with something else (if they support it), and it might not be present at runtime.

As long as pkg_resources is required by the CLI, internetarchive should depend on setuptools via install_requires. The build-backend should also be specified in pyproject.toml, though that's unrelated to this issue.