简体   繁体   English

在Windows 10上使用Python 3.5安装open-cv

[英]Installing open-cv on Windows 10 with Python 3.5

I'm having some trouble installing open-cv I've tried several approaches but only succeeded in installing open-cv by downloading the wheel file from a website which I don't remember and running this command in the command prompt: pip3 install opencv_python-3.2.0-cp35-cp35m-win32.whl; 我在安装open-cv时遇到了一些麻烦,我尝试了几种方法,但仅通过从一个我不记得的网站上下载了wheel文件,并在命令提示符下运行以下命令,成功安装了open-cv: pip3 install opencv_python-3.2.0-cp35-cp35m-win32.whl;

I can now import cv2 ONLY if I'm on site-packages directory. 现在,只有在site-packages目录中时,才可以import cv2 If I get out of that folder (in CMD of course) I wont be able to import cv2 (getting a "no module found" message). 如果离开该文件夹(当然是CMD),则将无法导入cv2(得到“未找到模块”消息)。

If i didnt expressed myself well, these are the commands I proceed to run to be able to import cv2 inside "site-packages" directory using CMD: 如果我没有很好地表达自己的意见,那么我将使用以下命令来运行这些命令,以便能够使用CMD将cv2导入“ site-packages”目录中:

python 蟒蛇

import cv2 导入cv2

If I try this in another directory, it doesn't work. 如果我在另一个目录中尝试此操作,它将无法正常工作。 The same if I create a .py file and try to import cv2 如果创建一个.py文件并尝试导入cv2,则相同

You need to update your environment variables. 您需要更新环境变量。

  1. In search, go to the control panel 在搜索中,转到控制面板
  2. Click the Advanced system settings link. 单击高级系统设置链接。
  3. Click Environment Variables. 单击环境变量。 In the section System Variables, find the PYTHONPATH variable. 在“系统变量”部分中,找到PYTHONPATH变量。
  4. Click edit, and add the absolute path to your Lib directory 单击编辑,然后将绝对路径添加到您的Lib目录中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM