简体   繁体   English

cv2不会在PyCharm中导入

[英]cv2 won't import in PyCharm

I am using PyCharm community version 2017.3.1, and Python 2.7.1. 我正在使用PyCharm社区版本2017.3.1和Python 2.7.1。 I tried installing opencv through PyCharm but it kept giving me an error. 我尝试通过PyCharm安装opencv,但它一直给我一个错误。

File "C:/Users/user/PycharmProjects/cameratest/cameratest.py", line 2, in import cv2 ImportError: DLL load failed: %1 is not a valid Win32 application. 导入cv2 ImportError中的文件“ C:/Users/user/PycharmProjects/cameratest/cameratest.py”,第2行:DLL加载失败:%1不是有效的Win32应用程序。

I downloaded the opencv executable file and tried moving it to my Python 2.7 file but it would still not work, and I tried following the answer here but to no avail. 我下载了opencv可执行文件,并尝试将其移动到我的Python 2.7文件中,但仍然无法正常工作,我尝试按照此处的答案进行操作但无济于事。

Add the python executable to the windows directory path if operating in windows. 如果在Windows中操作,请将python可执行文件添加到Windows目录路径。

Copy where the python folder is located then 然后复制python文件夹所在的位置

on windows button search path 在Windows按钮搜索路径上

click "edit the system environment variables"-> environment variables->path 单击“编辑系统环境变量”->环境变量->路径

Go to end, and type ";" 转至结尾,然后输入“;” and paste the windows directory path. 并粘贴Windows目录路径。

Log off and log back in. Then try executing program. 注销并重新登录。然后尝试执行程序。

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

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