按照水哥的说法,python使用的是3.7.6,但是在安装
pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple 回车
这一步进行到一半报错, Building wheel for opencv-python (PEP 517) … error 下面还有些 Ninja等字样。
然后百度了搞了下,直接
Traceback (most recent call last):
File “d:\python\lib\runpy.py”, line 193, in _run_module_as_main
“main”, mod_spec)
File “d:\python\lib\runpy.py”, line 85, in run_code
exec(code, run_globals)
File "D:\python\Scripts\pip.exe_main.py", line 5, in
ModuleNotFoundError: No module named ‘pip’
分析原因是pip版本低了,然后现在pip被我弄崩了。看了
通过一下两条命令进行修复和升级。
C:\Users\ccn>python -m ensurepip
Looking in links: c:\Users\ccn\AppData\Local\Temp\tmpr52g88li
Requirement already satisfied: setuptools in d:\python\lib\site-packages (41.2.0)
Collecting pip
Installing collected packages: pip
Successfully installed pip-19.2.3
C:\Users\ccn>python -m pip install --upgrade pip
Collecting pip
Using cached https://files.pythonhosted.org/packages/4d/16/0a14ca596f30316efd412a60bdfac02a7259bf8673d4d917dc60b9a21812/pip-22.0.4-py3-none-any.whl
Installing collected packages: pip
Found existing installation: pip 19.2.3
Uninstalling pip-19.2.3:
Successfully uninstalled pip-19.2.3
Successfully installed pip-22.0.4
然后就可以装了
C:\Users\ccn>pip install opencv-python -i https://pypi.tuna.tsinghua.edu.cn/simple
WARNING: Ignoring invalid distribution -ip (d:\python\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\python\lib\site-packages)
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple
Collecting opencv-python
Downloading https://pypi.tuna.tsinghua.edu.cn/packages/48/c3/798bd7b8f78430f82ec0660b753106717e4e4bb8032ce56f77d8577cb24b/opencv_python-4.5.5.64-cp36-abi3-win_amd64.whl (35.4 MB)
---------------------------------------- 35.4/35.4 MB 1.6 MB/s eta 0:00:00
Collecting numpy>=1.14.5
Using cached https://pypi.tuna.tsinghua.edu.cn/packages/97/9f/da37cc4a188a1d5d203d65ab28d6504e17594b5342e0c1dc5610ee6f4535/numpy-1.21.6-cp37-cp37m-win_amd64.whl (14.0 MB)
WARNING: Ignoring invalid distribution -ip (d:\python\lib\site-packages)
Installing collected packages: numpy, opencv-python
WARNING: Ignoring invalid distribution -ip (d:\python\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\python\lib\site-packages)
Successfully installed numpy-1.21.6 opencv-python-4.5.5.64
WARNING: Ignoring invalid distribution -ip (d:\python\lib\site-packages)
WARNING: Ignoring invalid distribution -ip (d:\python\lib\site-packages)
C:\Users\ccn>