`pdm run myscript.py` results in `ModuleNotFoundError: No module named 'pkg_resources'`
See original GitHub issue- I have searched the issue tracker and believe that this is not a duplicate.
Steps to reproduce
The google-cloud-storage
package appears to depend on pkg_resources
, which is a module of setuptools
. setuptools
is not one of my project dependencies, but shouldn’t it be installed as part of the Python environment? Regardless, after ensuring it’s installed in the base environment, pdm run ...
still fails.
This works: python myscript.py
This doesn’t: pdm run python myscript.py
(see exception below)
I’m using Pyenv to mange my Python versions, and I ensured that my project is configured to use the correct interpreter. Also, pyenv which python
and pdm run pyenv which python
yield the same path.
Adding setuptools
to the project dependencies will resolve the error, but it’s a dependency of a dependency and it’s installed in the base environment anyway. Something seems buggy.
Actual behavior
Traceback (most recent call last):
File "/home/knjpythonanywhere/datarobot/powerschool/powerschool_sync/extract.py", line 10, in <module>
from google.cloud import storage
File "/home/knjpythonanywhere/datarobot/powerschool/__pypackages__/3.9/lib/google/cloud/storage/__init__.py", line 35, in <module>
from google.cloud.storage.batch import Batch
File "/home/knjpythonanywhere/datarobot/powerschool/__pypackages__/3.9/lib/google/cloud/storage/batch.py", line 30, in <module>
from google.cloud.storage._http import Connection
File "/home/knjpythonanywhere/datarobot/powerschool/__pypackages__/3.9/lib/google/cloud/storage/_http.py", line 19, in <module>
import pkg_resources
ModuleNotFoundError: No module named 'pkg_resources'
Expected behavior
pdm run myscript.py
should presumably have the same outcome as python myscript.py
when I’m running both commands in the same working directory.
Environment Information
PDM version: 1.13.4
Python Interpreter: /home/knjpythonanywhere/.pyenv/versions/3.9.11/bin/python (3.9)
Project Root: /home/knjpythonanywhere/datarobot/powerschool
Project Packages: /home/knjpythonanywhere/datarobot/powerschool/__pypackages__/3.9
{
"implementation_name": "cpython",
"implementation_version": "3.9.11",
"os_name": "posix",
"platform_machine": "x86_64",
"platform_release": "5.13.0-1017-aws",
"platform_system": "Linux",
"platform_version": "#19~20.04.1-Ubuntu SMP Mon Mar 7 12:53:12 UTC 2022",
"python_full_version": "3.9.11",
"platform_python_implementation": "CPython",
"python_version": "3.9",
"sys_platform": "linux"
}
Issue Analytics
- State:
- Created 2 years ago
- Comments:5
So
google-cloud-storage
fails to listsetuptools
as a dependency, you should add it:pdm add setuptools
I can confirm that
extract-nwk.site_packages = true
will solve it. However, it doesn’t seem to work using the global setting key:_.site_packages = true
. Should I open a new issue for that?