I installed pytorch via
conda install pytorch-cpu torchvision-cpu -c pytorch
And I also tried
pip3 install https://download.pytorch.org/whl/cpu/torch-1.0.1-cp36-cp36m-win_amd64.whl pip3 install torchvision
Both installed successfully!
But, it only works in jupiter notebook. Whenever I try to execute a script from the console, I get the error message: No module named "torch"
How can I fix this?
To install PyTorch, you have to run the installation command of PyTorch on your command prompt. This command is available on https://pytorch.org/. Select language and cuda version as per your requirement. Now, run python -version, and Conda -version command to check Conda and python packages are installed or not.
To install Anaconda, you will use the 64-bit graphical installer for PyTorch 3. x. Click on the installer link and select Run . Anaconda will download and the installer prompt will be presented to you.
Try to install PyTorch using pip:
First create a Conda environment using:
conda create -n env_pytorch python=3.6
Activate the environment using:
conda activate env_pytorch
Now install PyTorch using pip:
pip install torchvision
Note: This will install both torch and torchvision.
Now go to Python shell and import using the command:
import torch import torchvision
I installed on my macos by the official command:
conda install pytorch torchvision -c pytorch
but when I follow the official verification I get the same problem like yours.
Then I create a conda virtual environment:
conda create --name learnpytorch python=3.5
and install pytorch inside the environment:
conda install pytorch torchvision -c pytorch
run the verification, it works.
Hope these could help you.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With