chensong1995 / HybridPose

HybridPose: 6D Object Pose Estimation under Hybrid Representation (CVPR 2020)
MIT License
412 stars 64 forks source link

ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' (/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/PIL/__init__.py) #84

Closed monajalal closed 10 months ago

monajalal commented 10 months ago

I have this error with PIL when using your version of packages:

(hp) mona@mona-ThinkStation-P7:~/HP/HybridPose$ pip show pillow
Name: Pillow
Version: 9.4.0
Summary: Python Imaging Library (Fork)
Home-page: https://python-pillow.org
Author: Alex Clark (PIL Fork Author)
Author-email: aclark@python-pillow.org
License: HPND
Location: /home/mona/anaconda3/envs/hp/lib/python3.7/site-packages
Requires: 
Required-by: torchvision

This is despite being able to use Pillow separately: Screenshot from 2023-10-23 12-46-57

hp) mona@mona-ThinkStation-P7:~/HP/HybridPose$ LD_LIBRARY_PATH=lib/regressor:$LD_LIBRARY_PATH python src/train_core.py
Traceback (most recent call last):
  File "src/train_core.py", line 8, in <module>
    from lib.datasets.linemod import LinemodDataset
  File "/home/mona/HP/HybridPose/lib/datasets/linemod.py", line 2, in <module>
    from torchvision import transforms
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torchvision/__init__.py", line 2, in <module>
    from torchvision import datasets
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torchvision/datasets/__init__.py", line 9, in <module>
    from .fakedata import FakeData
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torchvision/datasets/fakedata.py", line 3, in <module>
    from .. import transforms
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torchvision/transforms/__init__.py", line 1, in <module>
    from .transforms import *
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 17, in <module>
    from . import functional as F
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torchvision/transforms/functional.py", line 5, in <module>
    from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION
ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' (/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/PIL/__init__.py)

also, when importing torchvision I get the same error:

(hp) mona@mona-ThinkStation-P7:~/HP/HybridPose$ python
Python 3.7.4 (default, Aug 13 2019, 20:35:49) 
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchvision
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torchvision/__init__.py", line 2, in <module>
    from torchvision import datasets
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torchvision/datasets/__init__.py", line 9, in <module>
    from .fakedata import FakeData
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torchvision/datasets/fakedata.py", line 3, in <module>
    from .. import transforms
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torchvision/transforms/__init__.py", line 1, in <module>
    from .transforms import *
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torchvision/transforms/transforms.py", line 17, in <module>
    from . import functional as F
  File "/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/torchvision/transforms/functional.py", line 5, in <module>
    from PIL import Image, ImageOps, ImageEnhance, PILLOW_VERSION
ImportError: cannot import name 'PILLOW_VERSION' from 'PIL' (/home/mona/anaconda3/envs/hp/lib/python3.7/site-packages/PIL/__init__.py)

also:

(hp) mona@mona-ThinkStation-P7:~/HP/HybridPose$ conda list
# packages in environment at /home/mona/anaconda3/envs/hp:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_openmp_mutex             5.1                       1_gnu  
_pytorch_select           0.2                       gpu_0  
blas                      1.0                         mkl  
ca-certificates           2023.08.22           h06a4308_0  
certifi                   2022.12.7        py37h06a4308_0  
cffi                      1.15.0           py37h7f8727e_0  
cudatoolkit               10.0.130                      0  
cudnn                     7.6.5                cuda10.0_0  
freetype                  2.12.1               h4a9f257_0  
giflib                    5.2.1                h5eee18b_3  
intel-openmp              2022.1.0          h9e868ea_3769  
joblib                    1.3.2                    pypi_0    pypi
jpeg                      9e                   h5eee18b_1  
lcms2                     2.12                 h3be6417_0  
lerc                      3.0                  h295c915_0  
libdeflate                1.17                 h5eee18b_1  
libedit                   3.1.20221030         h5eee18b_0  
libffi                    3.2.1             hf484d3e_1007  
libgcc-ng                 11.2.0               h1234567_1  
libgomp                   11.2.0               h1234567_1  
libpng                    1.6.39               h5eee18b_0  
libstdcxx-ng              11.2.0               h1234567_1  
libtiff                   4.5.1                h6a678d5_0  
libwebp                   1.2.4                h11a3e52_1  
libwebp-base              1.2.4                h5eee18b_1  
lz4-c                     1.9.4                h6a678d5_0  
mkl                       2020.2                      256  
mkl-service               2.3.0            py37he8ac12f_0  
mkl_fft                   1.3.0            py37h54f3939_0  
mkl_random                1.1.1            py37h0573a6f_0  
ncurses                   6.4                  h6a678d5_0  
ninja                     1.10.2               h06a4308_5  
ninja-base                1.10.2               hd09550d_5  
numpy                     1.19.2           py37h54aff64_0  
numpy-base                1.19.2           py37hfa32c7d_0  
openssl                   1.1.1w               h7f8727e_0  
pillow                    9.4.0            py37h6a678d5_0  
pip                       22.3.1           py37h06a4308_0  
pycparser                 2.21               pyhd3eb1b0_0  
python                    3.7.4                h265db76_1  
pytorch                   1.2.0           cuda100py37h938c94c_0  
readline                  7.0                  h7b6447c_5  
scikit-learn              0.21.3                   pypi_0    pypi
scipy                     1.7.3                    pypi_0    pypi
setuptools                65.5.1                   pypi_0    pypi
six                       1.16.0             pyhd3eb1b0_1  
sqlite                    3.33.0               h62c20be_0  
tk                        8.6.12               h1ccaba5_0  
torchvision               0.4.0           cuda100py37hecfc37a_0  
wheel                     0.38.4           py37h06a4308_0  
xz                        5.4.2                h5eee18b_0  
zlib                      1.2.13               h5eee18b_0  
zstd                      1.5.5                hc292b87_0  

and

(hp) mona@mona-ThinkStation-P7:~/HP/HybridPose$ conda env export > environment.yml
(hp) mona@mona-ThinkStation-P7:~/HP/HybridPose$ cat environment.yml 
name: hp
channels:
  - defaults
dependencies:
  - _libgcc_mutex=0.1=main
  - _openmp_mutex=5.1=1_gnu
  - _pytorch_select=0.2=gpu_0
  - blas=1.0=mkl
  - ca-certificates=2023.08.22=h06a4308_0
  - certifi=2022.12.7=py37h06a4308_0
  - cffi=1.15.0=py37h7f8727e_0
  - cudatoolkit=10.0.130=0
  - cudnn=7.6.5=cuda10.0_0
  - freetype=2.12.1=h4a9f257_0
  - giflib=5.2.1=h5eee18b_3
  - intel-openmp=2022.1.0=h9e868ea_3769
  - jpeg=9e=h5eee18b_1
  - lcms2=2.12=h3be6417_0
  - lerc=3.0=h295c915_0
  - libdeflate=1.17=h5eee18b_1
  - libedit=3.1.20221030=h5eee18b_0
  - libffi=3.2.1=hf484d3e_1007
  - libgcc-ng=11.2.0=h1234567_1
  - libgomp=11.2.0=h1234567_1
  - libpng=1.6.39=h5eee18b_0
  - libstdcxx-ng=11.2.0=h1234567_1
  - libtiff=4.5.1=h6a678d5_0
  - libwebp=1.2.4=h11a3e52_1
  - libwebp-base=1.2.4=h5eee18b_1
  - lz4-c=1.9.4=h6a678d5_0
  - mkl=2020.2=256
  - mkl-service=2.3.0=py37he8ac12f_0
  - mkl_fft=1.3.0=py37h54f3939_0
  - mkl_random=1.1.1=py37h0573a6f_0
  - ncurses=6.4=h6a678d5_0
  - ninja=1.10.2=h06a4308_5
  - ninja-base=1.10.2=hd09550d_5
  - numpy=1.19.2=py37h54aff64_0
  - numpy-base=1.19.2=py37hfa32c7d_0
  - openssl=1.1.1w=h7f8727e_0
  - pillow=9.4.0=py37h6a678d5_0
  - pip=22.3.1=py37h06a4308_0
  - pycparser=2.21=pyhd3eb1b0_0
  - python=3.7.4=h265db76_1
  - pytorch=1.2.0=cuda100py37h938c94c_0
  - readline=7.0=h7b6447c_5
  - six=1.16.0=pyhd3eb1b0_1
  - sqlite=3.33.0=h62c20be_0
  - tk=8.6.12=h1ccaba5_0
  - torchvision=0.4.0=cuda100py37hecfc37a_0
  - wheel=0.38.4=py37h06a4308_0
  - xz=5.4.2=h5eee18b_0
  - zlib=1.2.13=h5eee18b_0
  - zstd=1.5.5=hc292b87_0
  - pip:
      - joblib==1.3.2
      - scikit-learn==0.21.3
      - scipy==1.7.3
      - setuptools==65.5.1
prefix: /home/mona/anaconda3/envs/hp

and

$ lsb_release -a
LSB Version:    core-11.1.0ubuntu4-noarch:security-11.1.0ubuntu4-noarch
Distributor ID: Ubuntu
Description:    Ubuntu 22.04.3 LTS
Release:    22.04
Codename:   jammy

and

$ uname -a
Linux mona-ThinkStation-P7 6.2.0-34-generic #34~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep  7 13:12:03 UTC 2 x86_64 x86_64 x86_64 GNU/Linux
chensong1995 commented 10 months ago

Hi Mona,

This is likely related to https://stackoverflow.com/questions/59659146/could-not-import-pillow-version-from-pil.

I hope this helps! Let me know if you have further concerns.

monajalal commented 10 months ago

Thanks a lot

(hp) mona@mona-ThinkStation-P7:~/HP/HybridPose$ pip install "pillow<7"
Collecting pillow<7
  Downloading Pillow-6.2.2-cp37-cp37m-manylinux1_x86_64.whl (2.1 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 14.2 MB/s eta 0:00:00
Installing collected packages: pillow
  Attempting uninstall: pillow
    Found existing installation: Pillow 9.4.0
    Uninstalling Pillow-9.4.0:
      Successfully uninstalled Pillow-9.4.0
Successfully installed pillow-6.2.2