码迷,mamicode.com
首页 > 其他好文 > 详细

pip pytorch安装时出现的问题

时间:2017-12-01 18:39:40      阅读:1068      评论:0      收藏:0      [点我收藏+]

标签:repo   build   tin   技术   src   bootstrap   st3   依赖   alter   

执行安装命令

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安装时出现的问题

标签:repo   build   tin   技术   src   bootstrap   st3   依赖   alter   

原文地址:http://www.cnblogs.com/lindaxin/p/7943720.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!