Reputation: 55
Steps to reproduce:
I am using Anaconda on Windows to set up environment for this repo.
conda create --name pytorch-yolo
Then I install all dependencies with conda install --file requirements.txt
Which returns
PackagesNotFoundError: The following packages are not available from current channels:
- torch[version='>=1.2']
So I install pytorch with conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
When I am trying to evaluate the model from the following repo: https://github.com/eriklindernoren/PyTorch-YOLOv3 with python3 test.py --weights_path weights/yolov3.weights
inside conda environment, it returns the following error ModuleNotFoundError: No module named 'torch'
If I run a Jupyter lab or notebook, or even go with python inside conda terminal, torch is easily imported.
What I've already tried:
Almost everything from this thread: No module named "Torch"
Specifically, creating a new conda environment with python set to 3.8.2, installing torch to base and then to the environment.
I'm also using pyenv to set global python to 3.8.2, but that doesn't help at all.
conda list
shows I have pytorch installed
Can't wrap my head around this issue.
Upvotes: 0
Views: 4881
Reputation: 510
You are probably using the wrong python binary. Can you try python test.py --weights_path weights/yolov3.weights
?
I am not familiar with Windows terminal, but you can get the path to the binaries by using the where
command (which
for Linux):
(pytorch-yolo) C:\Users\RemiChauvenne>where python3
C:\Users\RemiChauvenne\AppData\Local\Microsoft\WindowsApps\python3.exe
(pytorch-yolo) C:\Users\RemiChauvenne>where python
C:\Users\RemiChauvenne\miniconda3\envs\pytorch-yolo\python.exe
C:\Users\RemiChauvenne\AppData\Local\Microsoft\WindowsApps\python.exe
We can see that python3
does not go to the python binary inside the conda environment, whereas python
is correctly linked to pytorch-yolo.
Upvotes: 5