Last week I had a working conda env I was using for a project. I have not touched the project in a week. I just went to run a python file (python file.py
) that had been running with no errors.
Now I get the following error:
Traceback (most recent call last):
File "file.py", line 2, in <module>
from torch.utils.data import Dataset, DataLoader
ModuleNotFoundError: No module named 'torch'
In an attempt to troubleshoot, I opened a python console and ran the following code:
>>> import torch
The result was the following error message:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ModuleNotFoundError: No module named 'torch'
If I check all the installed packages using conda list -n <env_name>
, I can see that PyTorch is in fact installed, just as it was last week.
...
pytorch 1.2.0 py3.7_cuda9.2.148_cudnn7.6.2_0 pytorch
...
torchvision 0.4.0 py37_cu92 pytorch
...
Here is what I see when I start python console using python
:
Python 3.7.4 (default, Aug 13 2019, 20:35:49)
[GCC 7.3.0] :: Anaconda, Inc. on linux
The output of python -c 'import sys; print(sys.path)
in the base env is:
['', '/home/<name>/anaconda3/lib/python37.zip', '/home/<name>/anaconda3/lib/python3.7', '/home/<name>/anaconda3/lib/python3.7/lib-dynload', '/home/<name>/anaconda3/lib/python3.7/site-packages']
I have not personally made any chages to PYTHONPATH
.
If I run python -c 'import sys; print(sys.path)'
with my conda env (non-base) active, I get:
['', '/home/<name>/anaconda3/envs/<env_name>/lib/python37.zip', '/home/<name>/anaconda3/envs/<env_name>/lib/python3.7', '/home/<name>/anaconda3/envs/<env_name>/lib/python3.7/lib-dynload', '/home/<name>/anaconda3/envs/<env_name>/lib/python3.7/site-packages']
This is totally bizarre, can't figure out what is going on, and what could have happened, over the course of the last week, without me touching the code or making any changes to Anaconda.