When using the torchvision package to process the image data set, we found that an error occurred: ModuleNotFoundError: No module named 'torchvision', which indicates that we may not have installed the torchvision package.
Table of contents
1.1 Check whether it is installed:
1.2 Install torchvision when not installed
1.3 The installed torchvision version is too low
2. Install torchaudio and torchtext
1. Install torchvision
1.1 Check whether it is installed:
Open Anaconda Prompt of Anaconda and enter:
conda list
Check whether torchvision is installed.
1.2 Install torchvision when not installed
We do not have torchvision installed here, so you can install it directly by typing:
pip install torchvision==0.4.1 -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
The next thing after -i is to select Douban source to prevent installation failure. Torchvision 0.4.1 is installed. Of course, you can also install it directly without selecting a version, that is:
pip install torchvision -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
The installation result is:
1.3 The installed torchvision version is too low
Just uninstall torchvision first and enter:
pip uninstall torchvision
You can uninstall torchvision, and then install it according to the content of 1.2.
2. Install torchaudio and torchtext
In addition, our commonly used data set loading includes torchaudio and torchtext, which can be installed following this example:
The code to install torchaudio is:
pip install torchaudio -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
The code to install torchtext is:
pip install torchtext -i http://pypi.douban.com/simple --trusted-host pypi.douban.com
The result of installing torchaudio is:
The result of installing torchtext is: