ImportError : numpy.core.multiarray를 가져 오지 못했습니다.
이 프로그램을 실행하려고합니다
import cv2
import time
cv.NamedWindow("camera", 1)
capture = cv.CaptureFromCAM(0)
while True:
img = cv.QueryFrame(capture)
cv.ShowImage("camera", img)
if cv.WaitKey(10) == 27:
break
cv.DestroyAllWindows()
하지만 numpy에 문제가 있습니다. opencv와 함께 pyschopy를 사용하고 있습니다. 내가 계속 얻는 문제는이 오류 보고서입니다.
RuntimeError : API 버전 7에 대해 모듈이 컴파일되었지만이 버전의 numpy는 6입니다.
역 추적 (가장 최근 통화) :
"C : \ Users \ John \ Documents \ EyeTracking \ Programs \ GetImage.py"파일 1 행
import cv2
ImportError : numpy.core.multiarray를 가져 오지 못했습니다.
psychopy 폴더에 numpy-1.6.1-py2.7이 있는데, 무엇이 잘못되었는지 혼란 스럽습니까?
편집 (삭제 된 답변)
다음 명령
pip install -U numpy
문제 해결에 도움이됩니다. could not load numpy.core.multiarray.
같은 오류가 발생하여 numpy 설치를 1.8.0으로 업데이트하여 해결할 수있었습니다.
pip install -U numpy
그 경우
pip install -U numpy
작동하지 않습니다 (sudo로도), 올바른 버전의 numpy를 사용하고 있는지 확인하십시오. 같은 "numpy.core.multiarray를 가져 오지 못했습니다"문제가 있었지만 1.8을 계속 설치하고 올바른 디렉토리에 설치한다고 가정했지만 사용중인 Python 버전에 1.6을 설치했기 때문입니다.
Mac 터미널에서 다음 명령을 사용하여 잘못된 numpy 버전을 찾았습니다.
python -c "import numpy;print numpy.__version__;print numpy.__file__";
이 명령은 내가 사용하고있는 numpy의 버전과 위치를 주었다 (1.6.2로 밝혀 짐). 이 위치로 이동하여 1.8의 numpy 폴더로 수동으로 교체하여 "numpy.core.multiarray를 가져 오지 못했습니다"문제를 해결했습니다. 잘만되면 누군가 이것이 유용하다고 생각합니다!
참고 : 명령의 경우 'version'및 'file'앞뒤에 이중 밑줄을 사용하십시오.
특정 버전을 원하는 경우 :
pip install numpy==1.8
시도하십시오 sudo pip install numpy --upgrade --ignore-installed
.
Mac OS 10.11에서 작동합니다.
위의 쉘이 작동하지 않으면 'Rootless'를 닫아야합니다.
python3을 사용하는 경우 다음 명령은 macos의 문제를 해결합니다.
python3 -m pip install numpy -I
업그레이드 핍이 필요할 수 있습니다.
pip install --upgrade pip
pip install -U numpy
나를 위해 conda와 함께 pygrib를 설치하고 가져올 때이 오류가 발생했습니다.
conda install -c conda-forge numpy
문제를 해결했다.
필자의 경우이 문제는 두 개의 Python 설치 (2.7 및 3.5)를 사용하고 pip가 내가 사용한 pip 버전에 관계없이 3.5 python 디렉토리에만 numpy를 설치했기 때문입니다.
대상 설치 디렉토리를 명시 적으로 지정하여 문제를 해결했습니다.
pip install --target c:\apps\python-2.7\Lib\site-packages numpy
나는이 오류를 이해하지 못하지만 아래 에서이 오류를 해결했습니다.
pip install -U opencv-python
도움이 되었기를 바랍니다.
내 경우에는 apt에서 설치하면 문제가 해결되었습니다.
You can try uninstall it from pip and install from apt (if you are using ubuntu etc.)
pip3 uninstall numpy
sudo apt-get install python3-numpy
pip install opencv-python==3.4.2.17 numpy==1.14.5
done the job for me!
After having a nightmare using the pip install -U numpy several months ago, I gave up. I went through installing CV2s and opencv without success.
I was using numpy ver 1.9.1 on python34 and the upgrade just kept stalling on on 1.9.
So I went to https://pypi.python.org/pypi/numpy and discovered the latest numpy version for my python3.4.
I downloaded the .whl file and copied it into the folder containing my python installation, C:\Python34, in my case.
I then ran pip intall on the file name and I can now import cv2 problem free.
Make sure you close down python before you start, obvious but essential
It worked for me. So you can try following command
$ pip install numpy -I
I had the same error message, after trying some of the suggested solutions without success, I found that I needed to run:
pip uninstall numpy
multiple times. Each time several different files were flagged for removal, from different versions of numpy that had accumulated on my system.
Once there was nothing left to uninstall, it was a matter of
pip install numpy
Hope this helps someone!
I was getting the same error and the problem was solved by updating my numpy installation from 1.7.1 to 1.12.1
pip install -U numpy
The followings were my cmd sequence when the error was occurred, slightly different from the above:
$ python
Python 2.7.12 |Anaconda 4.2.0 (x86_64)| (default, Jul 2 2016, 17:43:17)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import cv2
>>> import numpy as np
>>> from matplotlib import pyplot as plt
I Had the same error occurring as I was using the numpy version suggested by the requirements.txt in the repo. When I tried to 'import pandas as pd' this error occurred. Then the solution was to upgrade numpy version to 1.15.2 as the version suggested in the requirements was mismatching with pandas. I uninstalled the existing numpy version with pip and reinstalled the new version.
pip install numpy==1.15.2
Hope this helps someone
Although the question is very old, but I am willing to provide an answer right now, because the answers didn't worked for my case. (And I am pretty sure that they won't work either for many other user having same configuration as mine).
On El-Capitan OS if you will hit the command
pip install -U numpy
it is quite possible that it will not upgrade the numpy module. Reason being that El-Capiton is already shipped with some python module (Eg. six) and therefore it won't allow you to delete the older version of those module and replace it with new one (thats what "-U" flag in the above command is trying to do). It won't allow even with root permissions because of System Integrity Protection.
So to overcome this issue I am currently using virtualenv (to install and use virtualenv : Article) and inside my virtualenv, I am hiting the command to install. Everything is working fine for me inside the virtualenv now.
PS: You might also receive errors in some other pip packages installation which will try to upgrade the system packages (Eg. when you are installing virtualenvwrapper). So to install virtualenvwrapper hit pip install command with "--ignore-installed" flag.
pip install --ignore-installed package-name-here
I had the same issue, and here's how it's solved in my case.
I tried pip -U numpy
but it didn't upgrade numpy, but conda install
worked for me
ImportError: numpy.core.multiarray failed to import
admin@MacBook-Air$ pip install -U numpy
Requirement already up-to-date: numpy in /Users/admin/anaconda/lib/python2.7/site-packages
admin@MacBook-Air$ python
Python 2.7.12 |Anaconda 2.4.0 (x86_64)| (default, Jul 2 2016, 17:43:17)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
Anaconda is brought to you by Continuum Analytics.
Please check out: http://continuum.io/thanks and https://anaconda.org
>>> import numpy
numpy.version.version
>>> numpy.version.version
'1.7.1'
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>>
admin@MacBook-Air$
admin@MacBook-Air$ conda install numpy
Fetching package metadata .......
Solving package specifications: ..........
Package plan for installation in environment /Users/admin/anaconda:
The following packages will be downloaded:
package | build
---------------------------|-----------------
scikit-learn-0.18.1 | np111py27_0 4.9 MB
The following packages will be UPDATED:
numexpr: 2.3.0-np17py27_0 --> 2.6.1-np111py27_1
numpy: 1.7.1-py27_2 --> 1.11.2-py27_0
scikit-learn: 0.14.1-np17py27_1 --> 0.18.1-np111py27_0
scipy: 0.13.2-np17py27_1 --> 0.18.1-np111py27_0
Proceed ([y]/n)? y
Fetching packages ...
scikit-learn-0 100% |#################################################################| Time: 0:00:16 312.60 kB/s
Extracting packages ...
[ COMPLETE ]|####################################################################################| 100%
Unlinking packages ...
[ COMPLETE ]|####################################################################################| 100%
Linking packages ...
[ COMPLETE ]|####################################################################################| 100%
I had the same issue. Here is a description of the scenario and how I resolved it:
1) Installing opencv using the whl from http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv
2) I had jupyter notebook open and tried to "import cv2". I got an error about numpy version issues and so I updated numpy using "conda update numpy"
3) I had jupyter notebook open and tried to "import cv2" which gave the error about "numpy.core.multiarray failed to import"
3) I closed the jupyter notebook program (as opposed to closing just the notebook for shown in the browser), restarted jupyter notebook, did "import cv2", and the errors were gone.
If you are using python 3.x and using anaconda to install your packages. You will most probably have to update your numpy to version 1.13 and above.
conda install numpy==1.13
The following method works in Windows -
pip install --user numpy
I had the same error after installing python and opencv in my D: drive (C: runs on a SSD). The problem seemed to be that my execution path was inside the numpy folder. You can check if that's the issue with this code :
import numpy
numpy.version.version
In case it retrieves any error related to the execution path, execute your original code from elsewhere. That solved the could not load numpy.core.multiarray error for me
If the solution by David Ketcheson doesn't work, then I suggest is removing ~/.local/lib/python3.6/site-packages/ (depending on which python version you have), which is what finally worked for me.
This helped me
sudo pip3 install --upgrade --target=/home/<username>/.local/lib/python3.6/site-packages numpy
For me it was a two part. First:
pip uninstall numpy
Then @Oli Blum answer (thank you):
conda install -c conda-forge numpy
That did the trick for me
Encountered this when trying to import Pytorch. Solved it by uninstalling numpy repeatedly until no version was left on my Ubuntu and installing the newest version.
Run sudo pip uninstall numpy
. If it refuses to delete the package from a <location>
, run sudo rm -r <location>
. Repeat above until the first command doesn't do anything and import numpy
can't find the package within Python shell.
Install numpy using pip.
uninstall existing numpy and install opencv-python will resolve the issue
This worked with me sudo python -m pip install --upgrade numpy
The same error came for me. The problem is that you might have created a file called numpy.py. This file might coincide with numpy library. So, delete that numpy.py file and the problem gets solved.
참고URL : https://stackoverflow.com/questions/20518632/importerror-numpy-core-multiarray-failed-to-import
'Programing' 카테고리의 다른 글
AngularJs 앱을 작성할 때 Jade 또는 Handlebars를 사용하는 것은 무엇입니까 (0) | 2020.07.14 |
---|---|
파이썬에서 문자열로 유니 코드를 선언하는 이유는 무엇입니까? (0) | 2020.07.14 |
약속에 onFulfilled에 여러 가지 주장이있을 수 있습니까? (0) | 2020.07.14 |
Visual Studio 2008에서 후행 공백을 자동으로 제거하는 방법은 무엇입니까? (0) | 2020.07.14 |
잡히지 않는 오류 : SECURITY_ERR : 쿠키를 설정하려고 할 때 DOM 예외 18 (0) | 2020.07.14 |