1.1.首先在pycharm里面直接搜索cv2,显示no availble information,后面安装报错。
2.直接去终端安装,pip install opencv-python
,反应很慢,显示访问过时。
3.换镜像源在终端安装,pip install Pyinstaller -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com
,报错
Collecting opencv-python
WARNING: The repository located at mirrors.aliyun.com is not a trusted or secure host and is being ignored. If this repository is available via HTTPS we recommend you use HTTPS instead, otherwise you may silence this warning and allow it anyway with '--trusted-host mirrors.aliyun.com'.
ERROR: Could not find a version that satisfies the requirement opencv-python (from versions: none)
ERROR: No matching distribution found for opencv-python
WARNING: You are using pip version 19.2.3, however version 22.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
4.去掉3中trusted-host mirrors.aliyun.com,报错,并且要升级pip
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting opencv-python
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/7a/1c/e57fe138615c29b8d1442009057dd420c58d4773cb16112e914c9e7b47d8/opencv-python-4.6.0.66.tar.gz (90.3MB)
|████████████████████████████████| 90.3MB 504kB/s
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Requirement already satisfied: numpy>=1.14.5; python_version >= "3.7" in e:\studying software\python\lib\site-packages (from opencv-python) (1.23.4)
Building wheels for collected packages: opencv-python
Building wheel for opencv-python (PEP 517) ... error
ERROR: Command errored out with exit status 1:
command: 'e:\studying software\python\python.exe' 'e:\studying software\python\lib\site-packages\pip\_vendor\pep517\_in_process.py' build_wheel 'C:\Users\FANZHO~1\AppData\Local\Temp\tmpcpt_42_h'
cwd: C:\Users\fanzhonglin\AppData\Local\Temp\pip-install-oovhi8pw\opencv-python
Complete output (332 lines):后面报错省略。。。。
Failed to build opencv-python
ERROR: Could not build wheels for opencv-python which use PEP 517 and cannot be installed directly
WARNING: You are using pip version 19.2.3, however version 22.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
5.更新pip pip install --upgrade pip setuptools wheel,报错ERROR: Could not install packages due to an EnvironmentError: [WinError 5] 拒绝访问。: 'e:\\studying software\\python\\scripts\\pip.exe' Consider using the
–user option or check the permissions.
6.修复pip python -m ensurepip
7.再更新pip python -m pip install --upgrade pip
8.更新成功后,直接pip install opencv-python
,安装成功