在pycharm中升级pip失败和pip安装pytorch torchvision opencv
pytorch官網:
https://pytorch.org/get-started/locally/
查看版本:
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.
第一次用的這個命令:
python -m pip install–upgrade pip -i
顯然無法成功。。。。
然后這條命令試用了很多次:
python -m pip install -U --force-reinstall pip
報錯:
ERROR: Exception:
Traceback (most recent call last):
然后一同學說用鏡像安裝。。于是輸入:
python -m pip install --upgrade pip -i https://pypi.tuna.tsinghua.edu.cn/simple然后成功了。
之后安裝pytorch和torchvision的命令:
pip install torchvision=0.8.2 torchaudio=0.7.2 -f https://download.pytorch.org/whl/torch_stable.h
tml
報錯:
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
繼續報錯:(試了三四次
然后去官網搜指令
輸入:
pip install torchvision0.8.2+cpu torchaudio=0.7.2 -f https://download.pytorch.org/whl/torch_stable
.html
仍然不行:
然后去搜鏡像,輸入:
python -m pip install --upgrade torch torchvision -i https://pypi.tuna.tsinghua.edu.cn/simple
成功了。結果:
然后安裝opencv:
pip3 install opencv-contrib-python -i https://pypi.tuna.tsinghua.edu.cn/simple
簡單測試opencv:
代碼:
圖片是自己c盤下面存的一張圖片,其中路徑把\換成/
結果:
安裝opencv-python:
輸入
install sucessfully:
總結
以上是生活随笔為你收集整理的在pycharm中升级pip失败和pip安装pytorch torchvision opencv的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Ajax服务器响应简单实例
- 下一篇: 【笔记】opencv的python使用