갈루아의 반서재

728x90

다음과 같은 ImportError 가 발생하는 경우

ImportError: cannot import name '_validate_lengths' from 'numpy.lib.arraypad'


import numpy as np
import time
import sys
import os
import random
from skimage import io
import pandas as pd
from matplotlib import pyplot as plt
from shutil import copyfile

import cv2
import tensorflow as tf

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-4-f9b11444e339> in <module>
      4 import os
      5 import random
----> 6 from skimage import io
      7 import pandas as pd
      8 from matplotlib import pyplot as plt

~/anaconda3/envs/anya/lib/python3.7/site-packages/skimage/__init__.py in <module>
    165         _raise_build_error(e)
    166     # All skimage root imports go here
--> 167     from .util.dtype import (img_as_float32,
    168                              img_as_float64,
    169                              img_as_float,

~/anaconda3/envs/anya/lib/python3.7/site-packages/skimage/util/__init__.py in <module>
      6 from .apply_parallel import apply_parallel
      7 
----> 8 from .arraycrop import crop
      9 from ._regular_grid import regular_grid, regular_seeds
     10 from .unique import unique_rows

~/anaconda3/envs/anya/lib/python3.7/site-packages/skimage/util/arraycrop.py in <module>
      6 
      7 import numpy as np
----> 8 from numpy.lib.arraypad import _validate_lengths
      9 
     10 

ImportError: cannot import name '_validate_lengths' from 'numpy.lib.arraypad' (/home/founder/anaconda3/envs/anya/lib/python3.7/site-packages/numpy/lib/arraypad.py)

패키지 버전을 확인해보자. numpy 는 1.16.2, scikit-image 는 0.14.1 이다.

(anya) founder@merrow:~/fasterRCNN$ conda list
# packages in environment at /home/founder/anaconda3/envs/anya:
#
# Name                    Version                   Build  Channel
numpy                     1.16.2                   pypi_0    pypi
scikit-image              0.14.1           py37he6710b0_0    anaconda

skimage 패키지를 업그레이드해보자. 이제 skimage 가 기존 0.14.1 에서 0.14.2 로 업그레이드되었고, import error 가 해결되었음을 알 수 있다.

(anya) founder@merrow:~/fasterRCNN$ pip install --upgrade scikit-image
Collecting scikit-image
  Downloading https://files.pythonhosted.org/packages/b7/66/a7f7649e5abf9cf1a908134fe6b52f8c5bb4e4059e47dd497bd173a951c6/scikit_image-0.14.2-cp37-cp37m-manylinux1_x86_64.whl (25.3MB)
    100% |████████████████████████████████| 25.3MB 1.2MB/s
Installing collected packages: scikit-image
  Found existing installation: scikit-image 0.14.1
    Uninstalling scikit-image-0.14.1:
      Successfully uninstalled scikit-image-0.14.1
Successfully installed scikit-image-0.14.2

(anya) founder@merrow:~/fasterRCNN$ conda list
# packages in environment at /home/founder/anaconda3/envs/anya:
#
# Name                    Version                   Build  Channel
numpy                     1.16.2                   pypi_0    pypi
scikit-image              0.14.2                   pypi_0    pypi


728x90