我正试图在Windows 8.1中安装并运行OpenCV 3.0.0forpython3.4.2。
C:\Python34\Lib\site-packages
上了。最后,我转到Python 3.4.2的空闲状态并编写(在将fine复制到Python目录之前发生了这种情况):
import cv2
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import cv2
ImportError: No module named 'cv2'
在我将文件复制到Python目录后发生了这种情况:
import cv2
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
import cv2
ImportError: DLL load failed: The specified module could not be found.
我做错什么了?我不确定是否应该安装CMake和NumPy。
我也不知道如何使用这个网页(这么多人推荐), http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv,有很多Python库可用,包括PIL、OpenCV、VideoCapture等。。。
我想试着用下面的例子:
好的,我不应该使用Python3.4中Python2.7中的文件。这行不通。我删除了它,所以正如otterb建议的那样,我刚刚从http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv安装了opencv_python-3.0.0-cp34-none-win_amd64.whl包,但是这个文件是.whl而不是EXE文件,根据How do I install a Python package with a .whl file?我遵循了以下步骤:
转到命令提示符
将带有“cd”的目录更改为我下载文件的位置
并编写“pip install opencv_python-3.0.0-cp34-none-win_amd64.whl”
但我收到了以下红色信息:
Installing collected packages: opencv-python
Cleaning up...
Exception:
Traceback (most recent call last):
File "C:\Python34\lib\shutil.py", line 370, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 32] The process cannot access the file because it is
being used by another process: 'C:\\Users\\JOSEFG~1\\AppData\\Local\\Temp\\pip-n
kyo0c6u-build\\opencv_python-3.0.0.data\\data\\Lib\\site-packages\\cv2.pyd'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pip\commands\install.py", line 283, in run
requirement_set.install(install_options, global_options, root=options.root_p
ath)
File "C:\Python34\lib\site-packages\pip\req.py", line 1444, in install
requirement.remove_temporary_source()
File "C:\Python34\lib\site-packages\pip\req.py", line 761, in remove_temporary
_source
rmtree(self._temp_build_dir)
File "C:\Python34\lib\site-packages\pip\util.py", line 43, in rmtree
onerror=rmtree_errorhandler)
File "C:\Python34\lib\shutil.py", line 477, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 372, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Python34\lib\site-packages\pip\util.py", line 53, in rmtree_errorhandler
(exctype is PermissionError and value.args[3] == 5) #python3.3
IndexError: tuple index out of range
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\shutil.py", line 370, in _rmtree_unsafe
os.unlink(fullname)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\JOSEFG~1\\AppData\\Local\\Temp\\pip-nkyo0c6u-build\\opencv_python-3.0.0.data\\data\\Lib\\site-packages\\cv2.pyd'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pip\basecommand.py", line 122, in main
status = self.run(options, args)
File "C:\Python34\lib\site-packages\pip\commands\install.py", line 302, in run
requirement_set.cleanup_files(bundle=self.bundle)
File "C:\Python34\lib\site-packages\pip\req.py", line 1319, in cleanup_files
req.remove_temporary_source()
File "C:\Python34\lib\site-packages\pip\req.py", line 761, in remove_temporary_source
rmtree(self._temp_build_dir)
File "C:\Python34\lib\site-packages\pip\util.py", line 43, in rmtree
onerror=rmtree_errorhandler)
File "C:\Python34\lib\shutil.py", line 477, in rmtree
return _rmtree_unsafe(path, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 367, in _rmtree_unsafe
_rmtree_unsafe(fullname, onerror)
File "C:\Python34\lib\shutil.py", line 372, in _rmtree_unsafe
onerror(os.unlink, fullname, sys.exc_info())
File "C:\Python34\lib\site-packages\pip\util.py", line 53, in rmtree_errorhandler
(exctype is PermissionError and value.args[3] == 5) #python3.3
IndexError: tuple index out of range
Storing debug log for failure in C:\Users\me\pip\pip.log
这意味着仔细阅读后,文件是不安全的安装在我的电脑上
另外,pip应该是根据How do I install pip on Windows?运行前一个命令的最新命令。然后我在命令提示符下升级pip
python -m pip install -U pip
现在我有了7.1版。我通过写作知道:
pip --version
然后我又试了一次
pip install opencv_python-3.0.0-cp34-none-win_amd64.whl
但当我收到这条信息时,它似乎正在起作用:
C:\Users\Jose F Gomez D\Downloads>pip install opencv_python-3.0.0-cp34-none-win_amd64.whl
Requirement already satisfied (use --upgrade to upgrade): opencv-python==3.0.0 from file:///C:/Users/Jose%20F%20Gomez%20D/Downloads/opencv_python-3.0.0-cp34-none-win_amd64.whl in c:\python34\lib\site-packages
然后我在python shell中编写“import cv2”,但是有一个新的错误
ImportError: numpy.core.multiarray failed to import
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
import cv2
ImportError: numpy.core.multiarray failed to import
所以我用
pip install numpy
pip install scipy
<>但是它不工作,因为它需要C++ +/p>需要microsoft visual c++10时出错
我试图从VisualStudio的网页中找到“Visual C++ 2010 Express”,但没有链接到“微软Visual C++ 2010 Express”,所以我去页面{{a10},下载文件,执行它,现在我得到C++。
我再次转到命令提示符,试图安装NumPy和SciPy,但没有成功。路径中有错误:
ValueError: ['path']
好的,现在我尝试从以下位置安装NumPy和SciPy包:
http://sourceforge.net/projects/numpy/files/NumPy/
但它不起作用,所以我去了Gohike,http://www.lfd.uci.edu/~gohlke/pythonlibs/#numpy,在管理员模式下从命令提示符安装了NumPy和SciPy:
pip install scipy‑0.16.0‑cp34‑none‑win_amd64.whl
pip install numpy‑1.9.2+mkl‑cp34‑none‑win_amd64.whl
现在我试着写简历,但什么也没做。Uups,它是cv2,它在工作。我接下来写答案。
我已经使用
conda
(安装Anaconda 3-64bit)和以下命令(conda installation of OpenCV 3)成功地安装了OpenCV 3.1.0:请注意,唯一完整的安装是从GitHub存储库编译OpenCV库获得的。我发现conda安装和车轮上缺少一些功能(如冲浪检测)。
在Windows 8.1上安装OpenCV 3.0.0forpython3.4.2的正确方法是:
我需要:
opencv_python-3.0.0-cp34-none-win_amd64.whl
scipy‑0.16.0‑cp34‑none‑win_amd64.whl
numpy‑1.9.2+mkl‑cp34‑none‑win_amd64.whl
然后安装库。复制并粘贴:
pip安装opencv_python-3.0.0-cp34-none-win_amd64.whl
pip安装scipy∙0.16.0∙cp34∙none∙win_amd64.whl
pip安装numpy-1.9.2+mkl-cp34-none-win-u amd64.whl
仅此而已。
————————————————————————————————狡猾的Python
您可以使用pip安装whl文件,如:
是的,你说得对。Gohlke的包以前是一个EXE文件,但是OpenCV现在作为whl分发。对不起,我错过了。
这里有一个类似的堆栈溢出问题:How do I install a Python package with a .whl file?
相关问题 更多 >
编程相关推荐