torchvision - ImportError: No module named torchvision

torchvision - ImportError: No module named torchvision

image and video datasets and models for torch deep learning
The torchvision package consists of popular datasets, model architectures, and common image transformations for computer vision.

1. Installation

Anaconda:

conda install torchvision -c pytorch

pip:

pip install torchvision

From source:

python setup.py install

2. Documentation

You can find the API documentation on the pytorch website: https://pytorch.org/docs/master/torchvision/

3. ImportError: No module named torchvision

yongqiang@strong-sys:~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> 
>>> import torchvision
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named torchvision
>>> 
>>> exit()
yongqiang@strong-sys:~$
yongqiang@strong-sys:~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> 
>>> import torchvision
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named torchvision
>>> 
>>> exit()
yongqiang@strong-sys:~$

4. sudo pip install torchvision

yongqiang@strong-sys:~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> 
>>> import torchvision
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named torchvision
>>> 
>>> exit()
yongqiang@strong-sys:~$ 
yongqiang@strong-sys:~$ pip install torchvision
Collecting torchvision
  Downloading https://files.pythonhosted.org/packages/ca/0d/f00b2885711e08bd71242ebe7b96561e6f6d01fdb4b9dcf4d37e2e13c5e1/torchvision-0.2.1-py2.py3-none-any.whl (54kB)
    100% |████████████████████████████████| 61kB 402kB/s 
Collecting pillow>=4.1.1 (from torchvision)
  Downloading https://files.pythonhosted.org/packages/9a/f6/3b3c82c5c75cae471e02fb584136168d732e17ae9db2d21c5dc82f9790f8/Pillow-5.3.0-cp27-cp27mu-manylinux1_x86_64.whl (2.0MB)
    100% |████████████████████████████████| 2.0MB 2.9MB/s 
Requirement already satisfied: torch in /usr/local/lib/python2.7/dist-packages (from torchvision) (1.0.0a0+46ef2b2)
Requirement already satisfied: six in /usr/local/lib/python2.7/dist-packages (from torchvision) (1.11.0)
Requirement already satisfied: numpy in /usr/local/lib/python2.7/dist-packages (from torchvision) (1.15.3)
Installing collected packages: pillow, torchvision
Could not install packages due to an EnvironmentError: [Errno 13] 权限不够: '/usr/local/lib/python2.7/dist-packages/PIL'
Consider using the `--user` option or check the permissions.

yongqiang@strong-sys:~$ 
yongqiang@strong-sys:~$ sudo pip install torchvision
[sudo] yongqiang 的密码: 
The directory '/home/yongqiang/.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/yongqiang/.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 https://files.pythonhosted.org/packages/ca/0d/f00b2885711e08bd71242ebe7b96561e6f6d01fdb4b9dcf4d37e2e13c5e1/torchvision-0.2.1-py2.py3-none-any.whl (54kB)
    100% |████████████████████████████████| 61kB 413kB/s 
Collecting pillow>=4.1.1 (from torchvision)
  Downloading https://files.pythonhosted.org/packages/9a/f6/3b3c82c5c75cae471e02fb584136168d732e17ae9db2d21c5dc82f9790f8/Pillow-5.3.0-cp27-cp27mu-manylinux1_x86_64.whl (2.0MB)
    100% |████████████████████████████████| 2.0MB 1.4MB/s 
Requirement already satisfied: torch in /usr/local/lib/python2.7/dist-packages (from torchvision) (1.0.0a0+46ef2b2)
Requirement already satisfied: six in /usr/local/lib/python2.7/dist-packages (from torchvision) (1.11.0)
Requirement already satisfied: numpy in /usr/local/lib/python2.7/dist-packages (from torchvision) (1.15.3)
Installing collected packages: pillow, torchvision
Successfully installed pillow-5.3.0 torchvision-0.2.1
yongqiang@strong-sys:~$ 
yongqiang@strong-sys:~$ 
yongqiang@strong-sys:~$ 
yongqiang@strong-sys:~$ python
Python 2.7.12 (default, Dec  4 2017, 14:50:18) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import torchvision
>>> 
>>> exit()
yongqiang@strong-sys:~$ 
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Yongqiang Cheng

梦想不是浮躁,而是沉淀和积累。

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值