将自己OpenCV-Python-PyCharm开发环境的Python-3.6.8更换为python-3.9.10的详细过程记录

先卸载Python-3.6.8及安装与之相关的工具~

在这里插入图片描述
就是上面红框中圈着的三个
卸载的顺序为
Python 3.6.8(64-bit)

Python Launcher

Python 3.6 pywin32-304
Python 3.6 pywin32-304的作用见博客 https://blog.csdn.net/wenhao_ir/article/details/124970257

先卸载Python 3.6.8(64-bit)
在这里插入图片描述
在这里插入图片描述

再卸载Python Launcher~
Python Launcher的卸载一闪而过,所以就没有截图了。

最后卸载Python 3.6 pywin32-304~
在这里插入图片描述
看下路径
C:\Users\Administrator\AppData\Local\Programs\Python\Python36\Lib\site-packages
下还有哪些文件。

在这里插入图片描述
可见,这些包还是存在的~不过不要紧,我们也没必要急着删,因为我们要装的新版本将会安装在文件夹Python39下。

接下来重启一下系统,以确保安装新版本后不会有什么意外产生。

系统重启完成,接下来下载安装包,官方网址:
https://www.python.org/ftp/python/
https://www.python.org/ftp/python/3.9.10/
https://www.python.org/ftp/python/3.9.10/python-3.9.10-amd64.exe
在这里插入图片描述
下载速度有点慢~
所以下载完成之后将其传到了百度网盘,以便将来再次安装时使用。
python-3.9.10-amd64.exe 百度网盘下载链接:
链接:https://pan.baidu.com/s/10K46xMHa1L1wNVXqMK33XA?pwd=x73p
接下来开始安装…
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
安装之后查看一下系统环境变量吧!
在这里插入图片描述
C:\Users\Administrator\AppData\Local\Programs\Python\Python39
可以看出,系统环境变量已经更改过来了。
再用命令测试下否安装成功。
在这里插入图片描述
接下来安装几个必须的库。
先挂上Ti子,要不然可能速度会很慢…(从后面的过程来看,对于当下的pip版本,比如我现在用的21.2.4,是不能用图标为一只坐着的灰青色猫的Ti子的,所以此步千万不要挂上Ti子)

pip install numpy

在这里插入图片描述
速度慢到下载下来的文件不完整,报错之后给我提供了了下载地址:

C:\Users\Administrator>pip install numpy
Collecting numpy
  Downloading numpy-1.22.4-cp39-cp39-win_amd64.whl (14.7 MB)
     |██                              | 917 kB 8.3 kB/s eta 0:27:44
ERROR: THESE PACKAGES DO NOT MATCH THE HASHES FROM THE REQUIREMENTS FILE. If you have updated the package versions, please update the hashes. Otherwise, examine the package contents carefully; someone may have tampered with them.
    numpy from https://files.pythonhosted.org/packages/99/2e/de8dcdbe1579b96f202685d8811d864291c374ea5fce13c63c70fdaf905d/numpy-1.22.4-cp39-cp39-win_amd64.whl#sha256=f0725df166cf4785c0bc4cbfb320203182b1ecd30fee6e541c8752a92df6aa32:
        Expected sha256 f0725df166cf4785c0bc4cbfb320203182b1ecd30fee6e541c8752a92df6aa32
             Got        eca84eddb32f7d2c533068323f4ec0fabeece5efe89c06cff70f717442ded6bc

从中可以看出下载地址为:
https://files.pythonhosted.org/packages/99/2e/de8dcdbe1579b96f202685d8811d864291c374ea5fce13c63c70fdaf905d/numpy-1.22.4-cp39-cp39-win_amd64.whl
下载到本地后按照博文 https://blog.csdn.net/wenhao_ir/article/details/125260565
的方法安装numpy-1.22.4吧!

博主2022-06-14 11:25:25注:后来证明下面这种本地安装的方法是错的,正确的方法见博文 https://blog.csdn.net/wenhao_ir/article/details/125260565

cd F:\Download
F:
pip install numpy==1.22.4

去,报一大堆错~
在这里插入图片描述

F:\Download>pip install numpy==1.22.4
ERROR: Exception:
Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\cli\base_command.py", line 173, in _main
    status = self.run(options, args)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\cli\req_command.py", line 203, in wrapper
    return func(self, options, args)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\commands\install.py", line 315, in run
    requirement_set = resolver.resolve(
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 94, in resolve
    result = self._result = resolver.resolve(
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python39\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 472, in resolve
    state = resolution.resolve(requirements, max_rounds=max_rounds)
    ............

这是什么原因呢?不知道,估计还是与刚才下载失败有关吧,虽然我用本地的安装了,估计哪里没有刷新,还用得之前的下载的错的那个???
网上查了下,有一种解决方法是用Anaconda安装(Anaconda比较大,可以选择Miniconda),博文https://blog.csdn.net/weixin_40007668/article/details/110020680就是这样解决这个问题的。
我觉得用Anaconda还是比较复杂,明天起床后先再试下,不行再降一个版本试一下。记住试之前先挂Ti子~(后来的解决方法证明,此时千万不要挂Ti子)

起床了,继续试吧!先挂上Ti子再试~(后来的解决方法证明,此时千万不要挂Ti子)

cd F:\Download
F:
pip install numpy==1.22.4

仍然是下面这样:
在这里插入图片描述
降个版本吧,看下numpy有哪些版本…

pip install numpy==100

居然连上面的命令也是同样的报错:
在这里插入图片描述
看来这是pip自身的问题了…
网上查下解决办法…
哎…查了半天,不知道怎么办…有一篇提到说是因为存在着过时的pkg_resources版本造成的,链接 https://www.cnpython.com/qa/76133 我估计也是因为第一次装numpy时出现错误造成的,所以我觉定卸载掉Python,然后把相关目录全部删除,再重新装。对,就这样再试下。
在这里插入图片描述
C:\Users\Administrator\AppData\Local\Programs\Python\Python39
在这里插入图片描述
从上图可见,连Python39这个文件夹都不存在了,卸载的很干净,不过为了确保万无一失,还是重启一次吧!

重启好了,再装一次吧,这次就不贴截图了。还是贴一贴结果吧!
在这里插入图片描述
为了万无一失,这次我重启下系统~

重启好了,还是先来看看环境变量~
在这里插入图片描述
有了~
C:\Users\Administrator\AppData\Local\Programs\Python\Python39
接下来挂Ti子~(后来的解决方法证明,此时千万不要挂Ti子)
开始装numpy

cd F:\Download
F:
pip install numpy==1.22.4

仍然是一样的报错~
在这里插入图片描述
服了~
突然联想到昨天我最开始没挂Ti子前是没这个问题的~是不是因为Ti子的问题???关掉试一下吧!

关掉Ti子之后就成功了…
关掉的软件中包含下面这个关键词:
在这里插入图片描述
在这里插入图片描述
接下来安装 matplotlib

pip install matplotlib

安装成功…
在这里插入图片描述
从上需的截图我们还可以看出除了matplotlib-3.5.2,还附带安装了以下这些扩展库:

  • cycler-0.11.0
  • fonttools-4.33.3
  • kiwisolver-1.4.3
  • packaging-21.3
  • pillow-9.1.1
  • pyparsing-3.0.9
  • python-dateutil-2.8.2
  • six-1.16.0

运行下面三条命令测试一下安装成功没有:

python
import numpy as np
import matplotlib as plt

在这里插入图片描述
可以看出,没有问题。
接下来,安装OpenCV及其扩展库。

pip install opencv-python==4.1.2.30
F:\Download>pip install opencv-python==4.1.2.30
ERROR: Could not find a version that satisfies the requirement opencv-python==4.1.2.30 (from versions: 3.4.0.14, 3.4.10.37, 3.4.11.39, 3.4.11.41, 3.4.11.43, 3.4.11.45, 3.4.13.47, 3.4.14.51, 3.4.14.53, 3.4.15.55, 3.4.16.57, 3.4.16.59, 3.4.17.61, 3.4.17.63, 3.4.18.65, 4.3.0.38, 4.4.0.40, 4.4.0.42, 4.4.0.44, 4.4.0.46, 4.5.1.48, 4.5.2.52, 4.5.2.54, 4.5.3.56, 4.5.4.58, 4.5.4.60, 4.5.5.62, 4.5.5.64, 4.6.0.66)
ERROR: No matching distribution found for opencv-python==4.1.2.30
WARNING: You are using pip version 21.2.4; however, version 22.1.2 is available.
You should consider upgrading via the 'C:\Users\Administrator\AppData\Local\Programs\Python\Python39\python.exe -m pip install --upgrade pip' command.

在这里插入图片描述
那就装4.3.0.38版本吧,不对得先看下OpenCV的扩展库有没有与4.3.0.38相对应的版本~

pip install opencv-contrib-python==100
F:\Download>pip install opencv-contrib-python==100
ERROR: Could not find a version that satisfies the requirement opencv-contrib-python==100 (from versions: 3.4.11.45, 3.4.13.47, 3.4.14.51, 3.4.14.53, 3.4.15.55, 3.4.16.59, 3.4.17.61, 3.4.17.63, 3.4.18.65, 4.4.0.46, 4.5.1.48, 4.5.2.52, 4.5.2.54, 4.5.3.56, 4.5.4.58, 4.5.4.60, 4.5.5.62, 4.5.5.64, 4.6.0.66)
ERROR: No matching distribution found for opencv-contrib-python==100

在这里插入图片描述
可以看出,没有~
二者都有的的是4.4.0.46版本~所以我们安装4.4.0.46版本

pip install opencv-python==4.4.0.46

安装成功…
在这里插入图片描述

pip install opencv-contrib-python==4.4.0.46

安装成功…
在这里插入图片描述
测试下OpenCV安装成功没有…

python
import cv2 as cv
print(cv.__version__)

在这里插入图片描述
没问题的哦!

接下来,修改Pycharm工程中的解释器~
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
C:\Users\Administrator\AppData\Local\Programs\Python\Python39\python.exe
在这里插入图片描述
在这里插入图片描述
然后随便运行一个OpenCV编写的程序~
在这里插入图片描述
没问题…
至些,开发环境更换修改成功~

猜你喜欢

转载自blog.csdn.net/wenhao_ir/article/details/125263766