Upgrade pip failed in pycharm and pip install pytorch torchvision opencv

pytorch official website:
https://pytorch.org/get-started/locally/

View version:

pip --version
pip 20.2.3 from c:\users\14172\pycharmprojects\pythonproject3\venv\lib\site-packages\pip (python 3.9)
python
Python 3.9.0 (tags/v3.9.0:9cf6752, Oct 5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.

The command used for the first time:
python -m pip install-upgrade pip -i
obviously cannot succeed. . . .
Insert picture description here

Then this command was tried many times:

python -m pip install -U --force-reinstall pip

报错:
ERROR: Exception:
Traceback (most recent call last):
Insert picture description here
Insert picture description here

Then a student said to install with mirroring. . So enter:

python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple

Then it succeeded.
Insert picture description here

Then install pytorch and torchvision commands:

pip install torchvision=0.8.2 torchaudio= 0.7.2 -f https://download.pytorch.org/whl/torch_stable.h
tml

Error:
Insert picture description here

RROR: Exception:
Traceback (most recent call last):
File “c:\users\14172\pycharmprojects\pythonproject3\venv\lib\site-packages\pip_vendor\resolvelib\resolvers.py”, line 171, in _merge_into_criterion
crit = self.state.criteria[name]
KeyError: ‘pillow’

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File “c:\users\14172\pycharmprojects\pythonproject3\venv\lib\site-packages\pip_vendor\urllib3\response.py”, line 438, in _error_catcher
yield
然后用命令:

pip install torchvision

Continue to report the error: (try three or four times
Insert picture description here
and then go to the official website to search for instructions and
enter:

pip install torchvision0.8.2+cpu torchaudio=0.7.2 -f https://download.pytorch.org/whl/torch_stable
.html

Still not working:
Insert picture description here

Then go to search the mirror, enter:

python -m pip install --upgrade torch torchvision -i https://pypi.tuna.tsinghua.edu.cn/simple

It succeeded. Result:
Insert picture description here
Then install opencv:

pip3 install opencv-contrib-python -i https://pypi.tuna.tsinghua.edu.cn/simple

Insert picture description here

Simple test opencv:
code:

import cv2 as cv


if __name__ == '__main__':
    src = cv.imread("C:/Users/14172/Pictures/pp.png")

    cv.namedWindow("图片", cv.WINDOW_AUTOSIZE)
   
    cv.imshow("picture", src)
    ###显示图片
    cv.waitKey(0)
    ###等待下一步指令
    cv.destroyAllWindows()

The picture is a picture saved under my own c drive, where the path is replaced with /
result:
Insert picture description here

Install opencv-python:
enter

pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python

install sucessfully:
Insert picture description here

Guess you like

Origin blog.csdn.net/qq_41358574/article/details/113093566