Numpy: ModuleNotFoundError: 'numpy.core._multiarray_umath'λΌλŠ” λͺ¨λ“ˆμ΄ μ—†μŠ΅λ‹ˆλ‹€.

에 λ§Œλ“  2019λ…„ 01μ›” 22일  Β·  9μ½”λ©˜νŠΈ  Β·  좜처: numpy/numpy

μ•ˆλ…•,

#11871κ³Ό μœ μ‚¬ν•œ λ¬Έμ œκ°€ μžˆμŠ΅λ‹ˆλ‹€. μ΅œκ·Όμ— numpy 1.16.0을 μ„€μΉ˜ν–ˆμ§€λ§Œ λ‹€μš΄κ·Έλ ˆμ΄λ“œν•΄μ•Ό ν–ˆκ³  μ§€κΈˆ 계속 ModuleNotFoundError: No module named 'numpy.core._multiarray_umath' λ°›κ³  μžˆμŠ΅λ‹ˆλ‹€.
μ•„λž˜ μ˜ˆμ œλŠ” 일주일 정도 전에 잘 μž‘λ™ν–ˆμŠ΅λ‹ˆλ‹€.

μ €λŠ” μ‹€μ œλ‘œ ipyparallel 및 openbabel μ œμ™Έν•˜κ³  apt-get (Ubuntu 18.04.1 LTS)λ₯Ό μ‚¬μš©ν•˜μ—¬ λͺ¨λ“  Python νŒ¨ν‚€μ§€( 지침 here )λ₯Ό μ œκ±°ν•˜κ³  ν•˜λ‚˜μ”© λ‹€μ‹œ μ„€μΉ˜ν–ˆμŠ΅λ‹ˆλ‹€. pip μ‚¬μš©ν•˜μ—¬ μ„€μΉ˜λ˜μ—ˆμŠ΅λ‹ˆλ‹€(λ‘˜ λ‹€ λ¬Έμ œμ™€ 관련이 μ—†λ‹€κ³  ν™•μ‹ ν•©λ‹ˆλ‹€). μ•„λž˜ μ˜ˆλŠ” 이 λͺ¨λ“  정리 _after_ μ‹€ν–‰λ˜μ—ˆμŠ΅λ‹ˆλ‹€.

λ§Žμ€ μ‚¬λžŒλ“€μ΄ μ΅œκ·Όμ— λ‹€λ₯Έ νŒ¨ν‚€μ§€μ™€ ν•¨κ»˜ 이 문제λ₯Ό κ²ͺκ³  μžˆλŠ” 것 κ°™μŠ΅λ‹ˆλ‹€.

μ½”λ“œ 예제 및 였λ₯˜ λ©”μ‹œμ§€ μž¬μƒμ„±:

λ‹€μŒμ€ 였λ₯˜λ₯Ό λ³΄μ—¬μ£ΌλŠ” IPython μ„Έμ…˜μž…λ‹ˆλ‹€.

% ipython3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
Type "copyright", "credits" or "license" for more information.

IPython 5.5.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import pandas as pd

In [2]: pd.read_hdf("data.h5")
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-122d644764c1> in <module>()
----> 1 pd.read_hdf("data.h5")

/usr/lib/python3/dist-packages/pandas/io/pytables.py in read_hdf(path_or_buf, key, mode, **kwargs)
    368                                      'contains multiple datasets.')
    369             key = candidate_only_group._v_pathname
--> 370         return store.select(key, auto_close=auto_close, **kwargs)
    371     except:
    372         # if there is an error, close the store

/usr/lib/python3/dist-packages/pandas/io/pytables.py in select(self, key, where, start, stop, columns, iterator, chunksize, auto_close, **kwargs)
    715                            chunksize=chunksize, auto_close=auto_close)
    716 
--> 717         return it.get_result()
    718 
    719     def select_as_coordinates(

/usr/lib/python3/dist-packages/pandas/io/pytables.py in get_result(self, coordinates)
   1455 
   1456         # directly return the result
-> 1457         results = self.func(self.start, self.stop, where)
   1458         self.close()
   1459         return results

/usr/lib/python3/dist-packages/pandas/io/pytables.py in func(_start, _stop, _where)
    708             return s.read(start=_start, stop=_stop,
    709                           where=_where,
--> 710                           columns=columns, **kwargs)
    711 
    712         # create the iterator

/usr/lib/python3/dist-packages/pandas/io/pytables.py in read(self, start, stop, **kwargs)
   2902             blk_items = self.read_index('block%d_items' % i)
   2903             values = self.read_array('block%d_values' % i,
-> 2904                                      start=_start, stop=_stop)
   2905             blk = make_block(values,
   2906                              placement=items.get_indexer(blk_items))

/usr/lib/python3/dist-packages/pandas/io/pytables.py in read_array(self, key, start, stop)
   2457 
   2458         if isinstance(node, tables.VLArray):
-> 2459             ret = node[0][start:stop]
   2460         else:
   2461             dtype = getattr(attrs, 'value_type', None)

/usr/lib/python3/dist-packages/tables/vlarray.py in __getitem__(self, key)
    669                 key += self.nrows
    670             (start, stop, step) = self._process_range(key, key + 1, 1)
--> 671             return self.read(start, stop, step)[0]
    672         elif isinstance(key, slice):
    673             start, stop, step = self._process_range(

/usr/lib/python3/dist-packages/tables/vlarray.py in read(self, start, stop, step)
    813         atom = self.atom
    814         if not hasattr(atom, 'size'):  # it is a pseudo-atom
--> 815             outlistarr = [atom.fromarray(arr) for arr in listarr]
    816         else:
    817             # Convert the list to the right flavor

/usr/lib/python3/dist-packages/tables/vlarray.py in <listcomp>(.0)
    813         atom = self.atom
    814         if not hasattr(atom, 'size'):  # it is a pseudo-atom
--> 815             outlistarr = [atom.fromarray(arr) for arr in listarr]
    816         else:
    817             # Convert the list to the right flavor

/usr/lib/python3/dist-packages/tables/atom.py in fromarray(self, array)
   1226         if array.size == 0:
   1227             return None
-> 1228         return six.moves.cPickle.loads(array.tostring())

ModuleNotFoundError: No module named 'numpy.core._multiarray_umath'

일뢀 κ΄€λ ¨ 파일 및 버전:

In [4]: import pandas as pd

In [5]: pd.__file__
Out[5]: '/usr/lib/python3/dist-packages/pandas/__init__.py'

In [6]: pd.__version__
Out[6]: '0.22.0'

In [7]: pd.__path__
Out[7]: ['/usr/lib/python3/dist-packages/pandas']

In [8]: import tables

In [9]: tables.__file__
Out[9]: '/usr/lib/python3/dist-packages/tables/__init__.py'

In [10]: tables.__version__
Out[10]: '3.4.2'

In [11]: tables.__path__
Out[11]: ['/usr/lib/python3/dist-packages/tables']

In [12]: import six

In [13]: six.__file__
Out[13]: '/usr/lib/python3/dist-packages/six.py'

In [14]: six.__version__
Out[14]: '1.11.0'

In [15]: six.__path__
Out[15]: []

Numpy/Python 버전 정보:

In [1]: import sys, numpy; print(numpy.__version__, sys.version)
1.13.3 3.6.7 (default, Oct 22 2018, 11:32:17) 
[GCC 8.2.0]

In [2]: import pandas; pandas.show_versions()

INSTALLED VERSIONS
------------------
commit: None
python: 3.6.7.final.0
python-bits: 64
OS: Linux
OS-release: 4.15.0-43-generic
machine: x86_64
processor: x86_64
byteorder: little
LC_ALL: None
LANG: en_GB.UTF-8
LOCALE: pt_BR.UTF-8

pandas: 0.22.0
pytest: None
pip: 9.0.1
setuptools: 40.6.3
Cython: None
numpy: 1.13.3
scipy: 0.19.1
pyarrow: None
xarray: None
IPython: 5.5.0
sphinx: None
patsy: 0.4.1+dev
dateutil: 2.6.1
pytz: 2018.3
blosc: None
bottleneck: None
tables: 3.4.2
numexpr: 2.6.4
feather: None
matplotlib: 2.1.1
openpyxl: None
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: 4.6.0
html5lib: 0.999999999
sqlalchemy: None
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None

Ubuntu 18.04.1 LTSλ₯Ό μ‚¬μš©ν•˜κ³  μžˆμŠ΅λ‹ˆλ‹€.

% uname -a
Linux mothership 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

#11871μ—μ„œ @mattip은 λ‹€μŒκ³Ό 같이 μ–ΈκΈ‰ν–ˆμŠ΅λ‹ˆλ‹€.

c-extension λͺ¨λ“ˆ _multiarray_umath 은 numpy 1.16.0의 μƒˆλ‘œμš΄ κΈ°λŠ₯이며 μ–΄λ”˜κ°€μ— 버전 λ˜λŠ” μ˜ˆμƒ 버전이 ν˜Όν•©λ˜μ–΄ μžˆμŒμ„ λ‚˜νƒ€λ‚Ό 수 μžˆμŠ΅λ‹ˆλ‹€. 이 λ¬Έμ œλŠ” μ’…λ£Œλ˜μ—ˆμŠ΅λ‹ˆλ‹€. numpy에 λ¬Έμ œκ°€ μžˆλ‹€κ³  μƒκ°λ˜λ©΄ ν˜„μž¬ μˆ˜ν–‰ 쀑인 μž‘μ—…μ— λŒ€ν•΄ μžμ„Ένžˆ μ„€λͺ…ν•˜λŠ” μƒˆ 문제λ₯Ό μ—¬μ‹­μ‹œμ˜€.

numpy 1.13.3이 μžˆλŠ”λ°λ„ 이 였λ₯˜κ°€ λ°œμƒν•˜λŠ” μ΄μœ λŠ” λ¬΄μ—‡μž…λ‹ˆκΉŒ? λͺ¨λ“  도움에 κ°μ‚¬λ“œλ¦½λ‹ˆλ‹€!

κ°€μž₯ μœ μš©ν•œ λŒ“κΈ€

참고둜, λ‹€μŒκ³Ό 같이 numpy 및 pandasλ₯Ό κ°•μ œλ‘œ λ‹€μ‹œ μ„€μΉ˜ν•˜μ—¬ 이 문제λ₯Ό ν•΄κ²°ν–ˆμŠ΅λ‹ˆλ‹€.

pip install --upgrade --force-reinstall numpy==1.14.5
pip install --upgrade --force-reinstall pandas==0.22.0

더 이상 였λ₯˜ λ©”μ‹œμ§€κ°€ μ—†μŠ΅λ‹ˆλ‹€.

λͺ¨λ“  9 λŒ“κΈ€

numpy 1.13.3의 numpy 1.16에 μ €μž₯된 배열을 unpicklingν•˜λŠ” 것 κ°™μŠ΅λ‹ˆλ‹€.

이것은 μ§„μ§œ λ²„κ·Έμ²˜λŸΌ λ³΄μž…λ‹ˆλ‹€. 이전 버전과 ν˜Έν™˜λ˜λ„λ‘ ndarray.__module__ λ₯Ό μž¬μ •μ˜ν•΄μ•Ό ν•  μˆ˜λ„ μžˆμŠ΅λ‹ˆλ‹€.

@tzickel 이 λ§žλ‹€κ³  μƒκ°ν•©λ‹ˆλ‹€. 방금 data.h5 λ₯Ό μ²˜μŒλΆ€ν„° λ‹€μ‹œ μƒμ„±ν–ˆκ³ (μ΄λŠ” 슀크립트λ₯Ό μ‚¬μš©ν•©λ‹ˆλ‹€. μ΄λ²ˆμ—λŠ” ν™•μ‹€νžˆ numpy 1.13.3을 μ‚¬μš©ν•¨) μœ„μ˜ μ½”λ“œκ°€ μž‘λ™ν–ˆμŠ΅λ‹ˆλ‹€.

% ipython3
Python 3.6.7 (default, Oct 22 2018, 11:32:17) 
Type "copyright", "credits" or "license" for more information.

IPython 5.5.0 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.

In [1]: import pandas as pd

In [2]: df = pd.read_hdf("data.h5")

In [3]: df.columns
Out[3]: 
Index(['aonames', 'atombasis', 'atomcharges', 'atomcoords', 'atommasses',
       'atomnos', 'charge', 'coreelectrons', 'enthalpy', 'entropy',
       'freeenergy', 'gbasis', 'geotargets', 'geovalues', 'grads', 'homos',
       'jobfilename', 'metadata', 'mocoeffs', 'moenergies', 'moments',
       'mosyms', 'mult', 'natom', 'nbasis', 'nmo', 'optdone', 'optstatus',
       'polarizabilities', 'pressure', 'scfenergies', 'scftargets',
       'scfvalues', 'temperature', 'vibdisps', 'vibfreqs', 'vibirs',
       'vibsyms'],
      dtype='object')

In [4]: df["freeenergy"].head()
Out[4]: 
0   -228.614123
1   -229.062884
2   -552.464074
3   -552.010916
4   -552.006776
Name: freeenergy, dtype: float64

λ‚˜λŠ” 그것이 ν•΄κ²°λ˜μ—ˆλ‹€κ³  μƒκ°ν•˜κΈ° λ•Œλ¬Έμ— 이것을 λ‹«μŠ΅λ‹ˆλ‹€. @tzickel κ°μ‚¬ν•©λ‹ˆλ‹€!

이 였λ₯˜κ°€ ν•΄κ²°λ˜μ—ˆλ‹€κ³  μƒκ°ν•˜μ§€ μ•ŠμŠ΅λ‹ˆλ‹€. μ €λŠ” 피클 νŒŒμΌμ„ μ‚¬μš©ν•˜μ§€ μ•Šκ³  μžˆλŠ”λ° 이와 λ˜‘κ°™μ€ 였λ₯˜κ°€ λ°œμƒν•©λ‹ˆλ‹€.

λ‚΄ MAC에 λͺ‡ 가지 λ³€κ²½ 사항이 있기 λ•Œλ¬Έμ— μ΅œκ·Όμ— 이 였λ₯˜κ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€. λͺ¨λ“  λͺ¨λ²” 사둀λ₯Ό λ”°λžμ§€λ§Œ 이 였λ₯˜λ₯Ό ν•΄κ²°ν•  수 μ—†λŠ” 것 κ°™μŠ΅λ‹ˆλ‹€.

MAC High Sierra(10.13.6)둜 μ—…κ·Έλ ˆμ΄λ“œ

python 3.6κ³Ό python 3.7을 λͺ¨λ‘ μ„€μΉ˜ν•˜μ—¬ home-brewλ₯Ό μ‚¬μš©ν•˜μ—¬ λ‚˜λž€νžˆ μ‹€ν–‰ν•˜κ³  여기에 μ œμ‹œλœ 지침을 λ”°λžμŠ΅λ‹ˆλ‹€.
https://stackoverflow.com/questions/51726203/installing-python3-6-alongside-python3-7-on-mac

python 3.6.5 및 기타 μ—¬λŸ¬ λͺ¨λ“ˆμ„ μ‚¬μš©ν•˜λ„λ‘ μƒˆ 가상 ν™˜κ²½μ„ μ„€μ •ν•©λ‹ˆλ‹€.

이 였λ₯˜λŠ” 가상 ν™˜κ²½μ—μ„œ λ°œμƒν•©λ‹ˆλ‹€. λ…ΈνŠΈλΆκ³Ό λͺ…령쀄 파이썬 μ½”λ“œ λͺ¨λ‘ 였λ₯˜λ₯Ό μƒμ„±ν•©λ‹ˆλ‹€. 파이썬 μ½”λ“œλŠ” 이 λ©”μ‹œμ§€ 외에 λ‹€λ₯Έ 였λ₯˜ 없이 100% μ˜¬λ°”λ₯΄κ²Œ μ‹€ν–‰λ©λ‹ˆλ‹€.

파이썬 my_py_file.py
ModuleNotFoundError: 'numpy.core._multiarray_umath'λΌλŠ” λͺ¨λ“ˆμ΄ μ—†μŠ΅λ‹ˆλ‹€.
ModuleNotFoundError: 'numpy.core._multiarray_umath'λΌλŠ” λͺ¨λ“ˆμ΄ μ—†μŠ΅λ‹ˆλ‹€.
ModuleNotFoundError: 'numpy.core._multiarray_umath'λΌλŠ” λͺ¨λ“ˆμ΄ μ—†μŠ΅λ‹ˆλ‹€.
ModuleNotFoundError: 'numpy.core._multiarray_umath'λΌλŠ” λͺ¨λ“ˆμ΄ μ—†μŠ΅λ‹ˆλ‹€.

venvλ₯Ό μ‚­μ œν•˜κ³  λ‹€μ‹œ μƒμ„±ν–ˆμ§€λ§Œ 였λ₯˜κ°€ μ§€μ†λ©λ‹ˆλ‹€. μ•„λ§ˆλ„ λͺ¨λ“  μ½”λ“œλŠ” λ‹€λ₯Έ 였λ₯˜ 없이 계속 싀행될 κ²ƒμž…λ‹ˆλ‹€.

λ‹€μŒμ— 무엇을 ν•΄μ•Ό 할지 잘 λͺ¨λ₯΄κ² μŠ΅λ‹ˆλ‹€. ν•΄κ²° 방법이 있으면 μ•Œλ €μ£Όμ„Έμš”. 그렇지 μ•ŠμœΌλ©΄ IMHOκ°€ 이 문제λ₯Ό μ’…λ£Œν•΄μ„œλŠ” μ•ˆ λ©λ‹ˆλ‹€.

μœ μ‚¬ν•œ λ¬Έμ œκ°€ μ—¬κΈ°μ—μ„œ μΆ”μ λ˜κ³  μžˆμŠ΅λ‹ˆλ‹€.
https://github.com/alpacahq/pylivetrader/issues/73

참고둜, λ‹€μŒκ³Ό 같이 numpy 및 pandasλ₯Ό κ°•μ œλ‘œ λ‹€μ‹œ μ„€μΉ˜ν•˜μ—¬ 이 문제λ₯Ό ν•΄κ²°ν–ˆμŠ΅λ‹ˆλ‹€.

pip install --upgrade --force-reinstall numpy==1.14.5
pip install --upgrade --force-reinstall pandas==0.22.0

더 이상 였λ₯˜ λ©”μ‹œμ§€κ°€ μ—†μŠ΅λ‹ˆλ‹€.

이 문제λ₯Ό ν•΄κ²°ν–ˆμŠ΅λ‹ˆλ‹€!

  1. numpy.load('myfile.py')μ—μ„œ λ™μΌν•œ λ¬Έμ œκ°€ λ°œμƒν–ˆμŠ΅λ‹ˆλ‹€.

역좔적(κ°€μž₯ 졜근 호좜 λ§ˆμ§€λ§‰):
파일 "", 1ν–‰, μ—μ„œ
파일 "/home/vivek/anaconda3/envs/Voiceattn/lib/python3.6/site-packages/numpy/lib/npyio.py", 라인 421, λ‘œλ“œ 쀑
pickle_kwargs=pickle_kwargs)
파일 "/home/vivek/anaconda3/envs/Voiceattn/lib/python3.6/site-packages/numpy/lib/format.py", 650ν–‰, read_array
λ°°μ—΄ = pickle.load(fp, **pickle_kwargs)
ModuleNotFoundError: 'numpy.core._multiarray_umath'λΌλŠ” λͺ¨λ“ˆμ΄ μ—†μŠ΅λ‹ˆλ‹€.

  1. Anaconda 가상 ν™˜κ²½ λ‚΄μ—μ„œ λ‹€μŒ ꡬ성이 제 κ²½μš°μ— 이 문제λ₯Ό ν•΄κ²°ν–ˆμŠ΅λ‹ˆλ‹€.

numpy 1.16.0
νŒ¬λ” 0.22.0
핍 18.1 py36_0
파이썬 3.6.8 h0371630_0

  1. OS X 버전: macOS High Sierra v10.13.6

도움이 λ˜μ—ˆκΈ°λ₯Ό λ°”λžλ‹ˆλ‹€!

이 문제λ₯Ό ν•΄κ²°ν–ˆμŠ΅λ‹ˆλ‹€!

1. I was getting the same issue in numpy.load('myfile.py'):

역좔적(κ°€μž₯ 졜근 호좜 λ§ˆμ§€λ§‰):
파일 "", 1ν–‰,
파일 "/home/vivek/anaconda3/envs/Voiceattn/lib/python3.6/site-packages/numpy/lib/npyio.py", 라인 421, λ‘œλ“œ 쀑
pickle_kwargs=pickle_kwargs)
파일 "/home/vivek/anaconda3/envs/Voiceattn/lib/python3.6/site-packages/numpy/lib/format.py", 650ν–‰, read_array
λ°°μ—΄ = pickle.load(fp, **pickle_kwargs)
ModuleNotFoundError: 'numpy.core._multiarray_umath'λΌλŠ” λͺ¨λ“ˆμ΄ μ—†μŠ΅λ‹ˆλ‹€.

1. Inside an Anaconda virtual env, the following config solved this issue in my case.

numpy 1.16.0
νŒ¬λ” 0.22.0
핍 18.1 py36_0
파이썬 3.6.8 h0371630_0

1. OS X version: macOS High Sierra v10.13.6

도움이 λ˜μ—ˆκΈ°λ₯Ό λ°”λžλ‹ˆλ‹€!

이 λ¬Έμ œκ°€ λ°œμƒν•˜μ—¬ μ €μ—κ²Œλ„ λ¬Έμ œκ°€ ν•΄κ²°λ˜μ—ˆμŠ΅λ‹ˆλ‹€. 감사 ν•΄μš”!

pip둜 numpyλ₯Ό μ—…λ°μ΄νŠΈν•˜λ©΄ μž‘λ™ν•©λ‹ˆλ‹€.

pip install --upgrade numpy

@mlsmall κ°μ‚¬ν•©λ‹ˆλ‹€. 그것은 λ§ˆμˆ μ΄λ‹€.

이 νŽ˜μ΄μ§€κ°€ 도움이 λ˜μ—ˆλ‚˜μš”?
0 / 5 - 0 λ“±κΈ‰