pip pytorch安裝時出現的問題
阿新 • • 發佈:2017-12-01
from parser pkg cte sat upgrading light pytho line
執行安裝命令
pip3 install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp35-cp35m-manylinux1_x86_64.whl
報錯如下
可以知道是pip的版本太舊了,因此要更新pip的版本,用如下命令
sudo apt install python-pip
但是又報依賴關系出現問題
Traceback (most recent call last): File "/usr/bin/pycompile", line 35, in <module> from debpython.version import SUPPORTED, debsorted, vrepr, File "/usr/share/python/debpython/version.py", line 24, in <module> from ConfigParser import SafeConfigParser ImportError: No module named ‘ConfigParser‘ dpkg: 處理軟件包 python-pip (--configure)時出錯: 子進程 已安裝 post-installation 腳本 返回錯誤狀態 1 正在設置 python-pkg-resources (20.7.0-1) ... Traceback (most recent call last): File "/usr/bin/pycompile", line 35, in <module> from debpython.version import SUPPORTED, debsorted, vrepr, File "/usr/share/python/debpython/version.py", line 24, in <module> from ConfigParser import SafeConfigParser ImportError: No module named ‘ConfigParser‘ dpkg: 處理軟件包 python-pkg-resources (--configure)時出錯: 子進程 已安裝 post-installation 腳本 返回錯誤狀態 1 dpkg: 依賴關系問題使得 python-setuptools 的配置工作不能繼續: python-setuptools 依賴於 python-pkg-resources (= 20.7.0-1);然而: 軟件包 python-pkg-resources 尚未配置。 dpkg: 處理軟件包 python-setuptools (--configure)時出錯: 依賴關系問題 - 仍未被配置 正在設置 python-wheel (0.29.0-1) ... 因為錯誤消息指示這是由於上一個問題導致的錯誤,沒有寫入 apport 報告。 Traceback (most recent call last): File "/usr/bin/pycompile", line 35, in <module> from debpython.version import SUPPORTED, debsorted, vrepr, File "/usr/share/python/debpython/version.py", line 24, in <module> from ConfigParser import SafeConfigParser ImportError: No module named ‘ConfigParser‘ dpkg: 處理軟件包 python-wheel (--configure)時出錯: 子進程 已安裝 post-installation 腳本 返回錯誤狀態 1 由於已經達到 MaxReports 限制,沒有寫入 apport 報告。 在處理時有錯誤發生: python-pip python-pkg-resources python-setuptools python-wheel E: Sub-process /usr/bin/dpkg returned an error code (1)
在安裝是無法識別 ConfigParser一些包無法正確安裝引起的,原因其實是我之前將python設為系統的默認版本,
在Python 3中, ConfigParser 被重命名為 configparser
如果默認版本是Python3執行更新操作會報錯
所以要切回python2才能正確安裝
解決方案:
切換Python版本
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 200 sudo update-alternatives --install /usr/bin/python python /usr/bin/python3 100
但是這樣還是無法解決pytorch無法安裝的問題,仍然報錯
You are using pip version 8.1.1, however version 9.0.1 is available. You should consider upgrading via the ‘pip install --upgrade pip‘ command.
但是pip install --upgrade pip並不能升級到version 9.0.1
解決方案:
使用wget安裝成功,具體如下: 1.sudo apt-get update 2.sudo apt-get upgrade 3.wget https://bootstrap.pypa.io/get-pip.py 4.sudo python3 get-pip.py apt-get install build-essential python-dev pip install uwsgi
但是不知道為什麽,當我執行命令pip3 install http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp35-cp35m-manylinux1_x86_64.whl時,
lai@lai-To-be-filled-by-O-E-M:~$ pip3 install torchvision bash: /usr/bin/pip3: 沒有那個文件或目錄
只有root權限才能正常安裝
lai@lai-To-be-filled-by-O-E-M:~$ sudo pip3 install torchvision The directory ‘/home/lai/.cache/pip/http‘ or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo‘s -H flag. The directory ‘/home/lai/.cache/pip‘ or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo‘s -H flag. Collecting torchvision Downloading torchvision-0.1.9-py2.py3-none-any.whl (43kB) 100% |████████████████████████████████| 51kB 88kB/s Requirement already satisfied: pillow in /usr/lib/python3/dist-packages (from torchvision) Requirement already satisfied: six in /usr/lib/python3/dist-packages (from torchvision) Requirement already satisfied: numpy in ./.local/lib/python3.5/site-packages (from torchvision) Requirement already satisfied: torch in ./.local/lib/python3.5/site-packages (from torchvision) Requirement already satisfied: pyyaml in ./.local/lib/python3.5/site-packages (from torch->torchvision) Installing collected packages: torchvision Successfully installed torchvision-0.1.9
pip pytorch安裝時出現的問題