pycharm中安装cv2失败,及其解决
1、在pycharm中安装CV2出现错误Non-zero exit code (1)
解决 :升级pip , 在终端cmd中输入python -m pip install --upgrade pip 但升级出现错误 :AttributeError: ‘NoneType’ object has no attribute ‘bytes’ 解决 :easy_install -U pip 2、升级后再在pycharm中安装CV2出错 :module ‘pip’ has no attribute ‘main’
解决 : 找到G:PyCharm 2017.1helperspackaging_tool.py文件(这里是我的PyCharm 安装路径,你需要找到你的相应的PyCharm 的安装路径) 打开找到如下代码 :
#104行左右,注意空格问题 def do_install(pkgs): try: import pip except ImportError: error_no_pip() return pip.main([install] + pkgs) def do_uninstall(pkgs): try: import pip except ImportError: error_no_pip() return pip.main([uninstall, -y] + pkgs)
替换成如下代码 :
def do_install(pkgs): try: try: from pip._internal import main except Exception: from pip import main except ImportError: error_no_pip(); return main([install] + pkgs); def do_uninstall(pkgs): try: try: from pip._internal import main except Exception: from pip import main except ImportError: error_no_pip(); return main([uninstall, -y] + pkgs);
3、得到解决。 但有时候不是每次都成功,若出现了问题’module’ object is not callable ,找到一种解决方法,先将2中改动的文件改回来 然后用pip install opencv-python在终端cmd中安装,完成