torchvision – ImportError: No module named torchvision

torchvision – ImportError: No module named torchvisiontorchvision-ImportError:NomodulenamedtorchvisionimageandvideodatasetsandmodelsfortorchdeeplearningThetorchvisionpackageconsistsofpopulardatasets,modelarchitectures,andcommonimagetransformationsforcomputervision.1.Installat

大家好,又见面了,我是你们的朋友全栈君。



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:~$ 
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/152611.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • Python中jieba库_python怎么写入文件

    Python中jieba库_python怎么写入文件Pythonjieba库用法及实例解析1、jieba库基本介绍(1)、jieba库概述jieba是优秀的中文分词第三方库-中文文本需要通过分词获得单个的词语-jieba是优秀的中文分词第三方库,需要额外安装-jieba库提供三种分词模式,最简单只需掌握一个函数(2)、jieba分词的原理Jieba分词依靠中文词库-利用一个中文词库,确定汉字之间的关联概率-汉字间概率大的组成词组,形成分…

    2022年9月21日
    3
  • C++函数指针、指针函数、返回值为函数指针的函数浅谈

    C++函数指针、指针函数、返回值为函数指针的函数浅谈C++函数指针、指针函数、返回值为函数指针的函数浅谈引言函数指针、指针函数是C中重要而容易混淆的概念,博主将通过两个实例来说明这两个截然不同的概念。而返回值为函数指针的指针函数就更难理解了,放在文章的最后来介绍。函数指针函数指针是一种特殊的指针,它指向函数的入口。例如int(*add)(int,int);定义了一个函数指针add,用于指向返回值为int,并且有两个int参数的函数…

    2022年6月22日
    27
  • List KeyValuePair

    List KeyValuePairList<KeyValuePair<string,string>>list=newList<KeyValuePair<string,string>>();list.Add(newKeyValuePair<string,string>(“asdf1″,”1”));list.Add(newKeyValuePair&l…

    2022年7月13日
    24
  • java input.nextline_关于java:Scanner#nextLine()留下一个剩余的换行符[通俗易懂]

    java input.nextline_关于java:Scanner#nextLine()留下一个剩余的换行符[通俗易懂]我一直遇到Scanner#nextLine的问题。根据我的理解,nextLine()应该返回当前输入流的其余部分,然后继续进行下一行。while(true){try{System.out.println(“Pleaseenteramonthinnumericform”);month=input.nextInt();System.out.println(“Pleaseenter…

    2022年5月11日
    39
  • Spring+MyBatis实例详解「建议收藏」

    Spring+MyBatis实例详解「建议收藏」1.项目结构:                2.项目的Maven依赖:&lt;properties&gt; &lt;spring-version&gt;4.3.21.RELEASE&lt;/spring-version&gt; &lt;/properties&gt; &lt;dependencies&gt; &lt;dependen…

    2022年6月24日
    21
  • C语言getchar的用法_getchar的用法

    C语言getchar的用法_getchar的用法getchargetchar的定义MSDN中的解释是从流中读取一个字符intch=getchar()//通过getchar获取字符的ASCII码值传到ch里面存储这里注意:getchar获取字符以后通过ASCII码值的形式存储在ch里为什么不用charch?getchar读到的是一个int类型的数据好处是返回值的时候非常方便接下来我们再看一个示例:intmain(){intch=0;while((ch=getch.

    2022年10月19日
    2

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号