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 'packaging' in pytorch-lightning 1.2.9 #7178

Closed
harupy opened this issue Apr 23, 2021 · 8 comments
Closed
Assignees
Labels
bug Something isn't working help wanted Open to be worked on priority: 0 High priority task

Comments

@harupy
Copy link

harupy commented Apr 23, 2021

🐛 Bug

Please reproduce using the BoringModel

To Reproduce

# Dockerfile
FROM python:3.7

RUN pip install pytorch-lightning
RUN pip list
RUN python -c "import pytorch_lightning"

This docker file outputs:

+ $ docker build .
Step 1/4 : FROM python:3.7
 ---> d3d53556f7be
Step 2/4 : RUN pip install pytorch-lightning
 ---> Running in cc421e414b5d
Collecting pytorch-lightning
  Downloading pytorch_lightning-1.2.9-py3-none-any.whl (841 kB)
Collecting fsspec[http]>=0.8.1
  Downloading fsspec-2021.4.0-py3-none-any.whl (108 kB)
Collecting torch>=1.4
  Downloading torch-1.8.1-cp37-cp37m-manylinux1_x86_64.whl (804.1 MB)
Collecting PyYAML!=5.4.*,>=5.1
  Downloading PyYAML-5.3.1.tar.gz (269 kB)
Collecting tqdm>=4.41.0
  Downloading tqdm-4.60.0-py2.py3-none-any.whl (75 kB)
Collecting future>=0.17.1
  Downloading future-0.18.2.tar.gz (829 kB)
Collecting numpy>=1.16.6
  Downloading numpy-1.20.2-cp37-cp37m-manylinux2010_x86_64.whl (15.3 MB)
Collecting tensorboard!=2.5.0,>=2.2.0
  Downloading tensorboard-2.4.1-py3-none-any.whl (10.6 MB)
Collecting torchmetrics==0.2.0
  Downloading torchmetrics-0.2.0-py3-none-any.whl (176 kB)
Collecting requests
  Downloading requests-2.25.1-py2.py3-none-any.whl (61 kB)
Collecting aiohttp
  Downloading aiohttp-3.7.4.post0-cp37-cp37m-manylinux2014_x86_64.whl (1.3 MB)
Collecting google-auth<2,>=1.6.3
  Downloading google_auth-1.29.0-py2.py3-none-any.whl (142 kB)
Collecting six>=1.10.0
  Downloading six-1.15.0-py2.py3-none-any.whl (10 kB)
Requirement already satisfied: wheel>=0.26 in /usr/local/lib/python3.7/site-packages (from tensorboard!=2.5.0,>=2.2.0->pytorch-lightning) (0.36.2)
Collecting grpcio>=1.24.3
  Downloading grpcio-1.37.0-cp37-cp37m-manylinux2014_x86_64.whl (4.2 MB)
Requirement already satisfied: setuptools>=41.0.0 in /usr/local/lib/python3.7/site-packages (from tensorboard!=2.5.0,>=2.2.0->pytorch-lightning) (54.2.0)
Collecting protobuf>=3.6.0
  Downloading protobuf-3.15.8-cp37-cp37m-manylinux1_x86_64.whl (1.0 MB)
Collecting werkzeug>=0.11.15
  Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
Collecting absl-py>=0.4
  Downloading absl_py-0.12.0-py3-none-any.whl (129 kB)
Collecting tensorboard-plugin-wit>=1.6.0
  Downloading tensorboard_plugin_wit-1.8.0-py3-none-any.whl (781 kB)
Collecting google-auth-oauthlib<0.5,>=0.4.1
  Downloading google_auth_oauthlib-0.4.4-py2.py3-none-any.whl (18 kB)
Collecting markdown>=2.6.8
  Downloading Markdown-3.3.4-py3-none-any.whl (97 kB)
Collecting rsa<5,>=3.1.4
  Downloading rsa-4.7.2-py3-none-any.whl (34 kB)
Collecting cachetools<5.0,>=2.0.0
  Downloading cachetools-4.2.1-py3-none-any.whl (12 kB)
Collecting pyasn1-modules>=0.2.1
  Downloading pyasn1_modules-0.2.8-py2.py3-none-any.whl (155 kB)
Collecting requests-oauthlib>=0.7.0
  Downloading requests_oauthlib-1.3.0-py2.py3-none-any.whl (23 kB)
Collecting importlib-metadata
  Downloading importlib_metadata-4.0.1-py3-none-any.whl (16 kB)
Collecting pyasn1<0.5.0,>=0.4.6
  Downloading pyasn1-0.4.8-py2.py3-none-any.whl (77 kB)
Collecting chardet<5,>=3.0.2
  Downloading chardet-4.0.0-py2.py3-none-any.whl (178 kB)
Collecting urllib3<1.27,>=1.21.1
  Downloading urllib3-1.26.4-py2.py3-none-any.whl (153 kB)
Collecting idna<3,>=2.5
  Downloading idna-2.10-py2.py3-none-any.whl (58 kB)
Collecting certifi>=2017.4.17
  Downloading certifi-2020.12.5-py2.py3-none-any.whl (147 kB)
Collecting oauthlib>=3.0.0
  Downloading oauthlib-3.1.0-py2.py3-none-any.whl (147 kB)
Collecting typing-extensions
  Downloading typing_extensions-3.7.4.3-py3-none-any.whl (22 kB)
Collecting yarl<2.0,>=1.0
  Downloading yarl-1.6.3-cp37-cp37m-manylinux2014_x86_64.whl (294 kB)
Collecting async-timeout<4.0,>=3.0
  Downloading async_timeout-3.0.1-py3-none-any.whl (8.2 kB)
Collecting multidict<7.0,>=4.5
  Downloading multidict-5.1.0-cp37-cp37m-manylinux2014_x86_64.whl (142 kB)
Collecting attrs>=17.3.0
  Downloading attrs-20.3.0-py2.py3-none-any.whl (49 kB)
Collecting zipp>=0.5
  Downloading zipp-3.4.1-py3-none-any.whl (5.2 kB)
Building wheels for collected packages: future, PyYAML
  Building wheel for future (setup.py): started
  Building wheel for future (setup.py): finished with status 'done'
  Created wheel for future: filename=future-0.18.2-py3-none-any.whl size=491059 sha256=e44f3bd35bd83da74e43e36a4d30e064d3bddbf0819c9bda821d706ca459492b
  Stored in directory: /root/.cache/pip/wheels/56/b0/fe/4410d17b32f1f0c3cf54cdfb2bc04d7b4b8f4ae377e2229ba0
  Building wheel for PyYAML (setup.py): started
  Building wheel for PyYAML (setup.py): finished with status 'done'
  Created wheel for PyYAML: filename=PyYAML-5.3.1-cp37-cp37m-linux_x86_64.whl size=471295 sha256=955ce05848ae5d47e8cdf9c7bd83d87a1a6c61525bd2e6206ba87c76467ce70f
  Stored in directory: /root/.cache/pip/wheels/5e/03/1e/e1e954795d6f35dfc7b637fe2277bff021303bd9570ecea653
Successfully built future PyYAML
Installing collected packages: urllib3, pyasn1, idna, chardet, certifi, zipp, typing-extensions, six, rsa, requests, pyasn1-modules, oauthlib, multidict, cachetools, yarl, requests-oauthlib, numpy, importlib-metadata, google-auth, attrs, async-timeout, werkzeug, torch, tensorboard-plugin-wit, protobuf, markdown, grpcio, google-auth-oauthlib, fsspec, aiohttp, absl-py, tqdm, torchmetrics, tensorboard, PyYAML, future, pytorch-lightning
Successfully installed PyYAML-5.3.1 absl-py-0.12.0 aiohttp-3.7.4.post0 async-timeout-3.0.1 attrs-20.3.0 cachetools-4.2.1 certifi-2020.12.5 chardet-4.0.0 fsspec-2021.4.0 future-0.18.2 google-auth-1.29.0 google-auth-oauthlib-0.4.4 grpcio-1.37.0 idna-2.10 importlib-metadata-4.0.1 markdown-3.3.4 multidict-5.1.0 numpy-1.20.2 oauthlib-3.1.0 protobuf-3.15.8 pyasn1-0.4.8 pyasn1-modules-0.2.8 pytorch-lightning-1.2.9 requests-2.25.1 requests-oauthlib-1.3.0 rsa-4.7.2 six-1.15.0 tensorboard-2.4.1 tensorboard-plugin-wit-1.8.0 torch-1.8.1 torchmetrics-0.2.0 tqdm-4.60.0 typing-extensions-3.7.4.3 urllib3-1.26.4 werkzeug-1.0.1 yarl-1.6.3 zipp-3.4.1
Removing intermediate container cc421e414b5d
 ---> b6c83e70007a
+ Step 3/4 : RUN pip list
 ---> Running in 18795a337c07
Package                Version
---------------------- -----------
absl-py                0.12.0
aiohttp                3.7.4.post0
async-timeout          3.0.1
attrs                  20.3.0
cachetools             4.2.1
certifi                2020.12.5
chardet                4.0.0
fsspec                 2021.4.0
future                 0.18.2
google-auth            1.29.0
google-auth-oauthlib   0.4.4
grpcio                 1.37.0
idna                   2.10
importlib-metadata     4.0.1
Markdown               3.3.4
multidict              5.1.0
numpy                  1.20.2
oauthlib               3.1.0
pip                    21.0.1
protobuf               3.15.8
pyasn1                 0.4.8
pyasn1-modules         0.2.8
+ pytorch-lightning      1.2.9
PyYAML                 5.3.1
requests               2.25.1
requests-oauthlib      1.3.0
rsa                    4.7.2
setuptools             54.2.0
six                    1.15.0
tensorboard            2.4.1
tensorboard-plugin-wit 1.8.0
torch                  1.8.1
torchmetrics           0.2.0
tqdm                   4.60.0
typing-extensions      3.7.4.3
urllib3                1.26.4
Werkzeug               1.0.1
wheel                  0.36.2
yarl                   1.6.3
zipp                   3.4.1
Removing intermediate container 18795a337c07
 ---> e836aaeac329
+ Step 4/4 : RUN python -c "import pytorch_lightning"
 ---> Running in 91abc4d0ac11
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/__init__.py", line 28, in <module>
    from pytorch_lightning import metrics  # noqa: E402
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/metrics/__init__.py", line 14, in <module>
    from pytorch_lightning.metrics.classification import (  # noqa: F401
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/metrics/classification/__init__.py", line 14, in <module>
    from pytorch_lightning.metrics.classification.accuracy import Accuracy  # noqa: F401
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/metrics/classification/accuracy.py", line 18, in <module>
    from pytorch_lightning.metrics.functional.accuracy import _accuracy_compute, _accuracy_update
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/metrics/functional/__init__.py", line 14, in <module>
    from pytorch_lightning.metrics.functional.accuracy import accuracy  # noqa: F401
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/metrics/functional/accuracy.py", line 18, in <module>
    from pytorch_lightning.metrics.classification.helpers import _input_format_classification, DataType
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/metrics/classification/helpers.py", line 19, in <module>
    from pytorch_lightning.metrics.utils import select_topk, to_onehot
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/metrics/utils.py", line 18, in <module>
    from pytorch_lightning.utilities import rank_zero_warn
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/utilities/__init__.py", line 18, in <module>
    from pytorch_lightning.utilities.apply_func import move_data_to_device  # noqa: F401
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/utilities/apply_func.py", line 25, in <module>
    from pytorch_lightning.utilities.imports import _compare_version, _TORCHTEXT_AVAILABLE
  File "/usr/local/lib/python3.7/site-packages/pytorch_lightning/utilities/imports.py", line 21, in <module>
    from packaging.version import Version
+ ModuleNotFoundError: No module named 'packaging'
The command '/bin/sh -c python -c "import pytorch_lightning"' returned a non-zero code: 1

Expected behavior

pytorch_lightning can be installed without any additional dependencies.

Environment

Note: Bugs with code are solved faster ! Colab Notebook should be made public !

You can get the script and run it with:

wget https://raw.githubusercontent.com/PyTorchLightning/pytorch-lightning/master/tests/collect_env_details.py
# For security purposes, please check the contents of collect_env_details.py before running it.
python collect_env_details.py
  • PyTorch Version (e.g., 1.0):
  • OS (e.g., Linux):
  • How you installed PyTorch (conda, pip, source):
  • Build command you used (if compiling from source):
  • Python version:
  • CUDA/cuDNN version:
  • GPU models and configuration:
  • Any other relevant information:

Additional context

@harupy harupy added bug Something isn't working help wanted Open to be worked on labels Apr 23, 2021
@harupy
Copy link
Author

harupy commented Apr 23, 2021

requirements.txt on 1.2.9 doesn't seem to contain packaging:

https://github.com/PyTorchLightning/pytorch-lightning/blob/1.2.9/requirements.txt#L1

# the default package dependencies

numpy>=1.16.6
torch>=1.4
future>=0.17.1  # required for builtins in setup.py
# pyyaml>=3.13
PyYAML>=5.1, !=5.4.*  # OmegaConf requirement >=5.1
tqdm>=4.41.0
fsspec[http]>=0.8.1
tensorboard>=2.2.0
torchmetrics>=0.2.0

@harupy
Copy link
Author

harupy commented Apr 23, 2021

I checked the tarball for 1.2.9 on PyPI using the following script:

# Fetch tarball for 1.2.9 from PyPi
curl https://files.pythonhosted.org/packages/09/b6/16e6e2247c0ac56461a0f98ed6055287320f035cc1d6effce36f3acb1f58/pytorch-lightning-1.2.9.tar.gz --output pytorch-lightning-1.2.9.tar.gz
tar -xvzf pytorch-lightning-1.2.9.tar.gz
# Check file contents
echo =======================================
cat pytorch-lightning-1.2.9/pytorch_lightning/utilities/imports.py | head -n 30
echo =======================================
cat pytorch-lightning-1.2.9/requirements.txt

This outputs:

...
=======================================
# Copyright The PyTorch Lightning team.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""General utilities"""
import importlib
import operator
import platform
from importlib.util import find_spec

import torch
+ from packaging.version import Version
from pkg_resources import DistributionNotFound


def _module_available(module_path: str) -> bool:
    """
    Check if a path is available in your environment

    >>> _module_available('os')
    True
=======================================
# the default package dependencies

numpy>=1.16.6
torch>=1.4
future>=0.17.1  # required for builtins in setup.py
# pyyaml>=3.13
PyYAML>=5.1, !=5.4.*  # OmegaConf requirement >=5.1
tqdm>=4.41.0
fsspec[http]>=0.8.1
tensorboard>=2.2.0, !=2.5.0  # 2.5.0 GPU CI error: 'Couldn't build proto file into descriptor pool!'
torchmetrics==0.2.0

requirements.txt doesn't seem to reflect this change in #6999

@Borda
Copy link
Member

Borda commented Apr 23, 2021

yeah it seems we made a mistake when we did resolve after cherry-picking, let us fix it very quick
cc: @kaushikb11

@kaushikb11
Copy link
Contributor

My bad. @Borda Should I do a PR to the release branch?

@Borda
Copy link
Member

Borda commented Apr 23, 2021

well at first place we shall check ho it was possible that all tests passed and we did not find catch it
second, already made the fix in release branch and ready to release quick fix 44bbfa3

@harupy
Copy link
Author

harupy commented Apr 23, 2021

@Borda Thanks for the quick fix 👍

@Borda Borda added the priority: 0 High priority task label Apr 23, 2021
@Borda
Copy link
Member

Borda commented Apr 23, 2021

@harupy just test for v1.2.10 and seems to be fine :]

@Borda Borda closed this as completed Apr 23, 2021
@harupy
Copy link
Author

harupy commented Apr 23, 2021

@Borda Confirmed the issue has been fixed! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Open to be worked on priority: 0 High priority task
Projects
None yet
Development

No branches or pull requests

3 participants