PayneLab/cptac

ModuleNotFoundError: No module named 'packaging'

Closed this issue · 4 comments

When importing the cptac module, I am getting the following error:

$ python -c"import cptac"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/gpfs/home/schrat01/cptac_test/lib/python3.7/site-packages/cptac/__init__.py", line 19, in <module>
    from .file_download import download
  File "/gpfs/home/schrat01/cptac_test/lib/python3.7/site-packages/cptac/file_download.py", line 16, in <module>
    from .file_tools import *
  File "/gpfs/home/schrat01/cptac_test/lib/python3.7/site-packages/cptac/file_tools.py", line 16, in <module>
    import packaging.version
ModuleNotFoundError: No module named 'packaging'

This looks to be the same issue as pypa/setuptools#937, however, I tried several setuptools versions (45.2.0, 40.9.0, 38.6.0, 36.7.2 and 32.3.1) and none worked.
What ended up doing the job is just conda install packaging.

Since all the top google results for the original problem pointed towards updating setuptools issues with regards to this error, I am not sure things are working as intended here.
Is packaging normally a requirement of setuptools? Because setuptools imported just fine, no idea why packaging was not installed when it was clearly required. Is this an issue with the pip recipe of the cptac package, or maybe an issue with the conda recipe for setuptools?

Thanks for bringing this up! We had someone else have the exact same problem. The issue arises from not having the packaging module installed, and as you found, installing packaging manually fixes it.

We didn't have the module required in cptac's details because it happened to be installed by default in our environments; we didn't realize that not everyone would have it by default. We've now added it to the pip install requirements, so in all future versions it will be installed automatically if someone doesn't already have it, when they install or update cptac.

So for now, if anyone else has this issue, they can fix it by installing the packaging module manually--either using pip install packaging or conda install packaging. And after the next cptac update, the issue will be prevented automatically.

Aaah ok, thanks for fixing it so quickly!

Yes!!! thank you!!! pip install packaging worked for me

I installed Transformers using pip. After installation, I wanted make sure the installation is running. So, I ran the command:

python -c "from transformers import pipeline; print(pipeline('sentiment-analysis')('we love you'))"

But I am getting following error, though I already installed packaging with pip in my virtual conda env:

Traceback (most recent call last):
File "", line 1, in
File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/init.py", line 26, in
from . import dependency_versions_check
File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/dependency_versions_check.py", line 16, in
from .utils.versions import require_version, require_version_core
File "/home/tasmia/anaconda3/envs/minigrid_dev/lib/python3.9/site-packages/transformers/utils/init.py", line 19, in
from packaging import version
ModuleNotFoundError: No module named 'packaging'

I have pip-23.3.1, transformers 4.34.1.

What else can be dome to resolve this?