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.
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.
Related
i'm working on a classifier that uses CNN and i need to use the keras tuner so i can find the best CNN architecture
i executed this command "pip install keras-tuner" and it was installed successfully
but when i import it "import keras_tuner as kt" and run the python script
No module named 'keras_tuner'
i'm working offline with python 3.7.9,tensorflow 2.0,keras 2.7 in VSCode
can someone help me? i really need to use the tuner
thanks
so i used
pip install keras_tuner
in VSCode and the packge was really installed but in the global site-packages folder and not in venv/lib folder
so all i did is that i went to venv/pyvenv.cfg file in VSCode
and set
include-system-site-packages = true
I had the same issue using PyCharm. When I installed the keras-tuner package in the Anaconda 3 prompt, I got the message that everything is already installed. The problem was, that the keras-tuner was installed in my base environment and not in the environment (virtual) which I use in PyCharm. You simply need to do the following.
check out your environments in the anaconda prompt using: conda env list
you will probably see the * on the base environment
now change to your working environment for example conda activate tf_cpu -> tf_cpu needs to be changed by your envs name (see on your list)
install your package such as pip install keras_tuner
I'm new to python and Anaconda
I have python 3.8 in my (base) env, and i need pybrain, so since it's not compatible with my current version of python, i created a new env(first i tried all of it with python 3.5, didn't work, so i tried 2.7, same result):
conda create --name py27 python=2.7
then activated it:
conda activate py27
and installed pybrain there:
conda install -c mq pybrain
I checked that it has been installed successfully with:
conda list
pybrain 0.3.3 py27_0 mq
after launching jupyter notebook from same terminal, with (py27) as the 'header'?? of my command line, it opened successfully, i even checked that currently it's opened in expected environment, by typing in a cell:
!conda info
and as i expected, saw the line
active environment : py27
but also, which i guess is importnant:
python version : 3.8.3.final.0
though i am confused with ouput of:
!python --version
cause it's:
Python 2.7.18 :: Anaconda, Inc.
So when i open my notebook i type
import pybrain
and i get:
No module named 'pybrain'
Please point me in direction: what i'm doing wrong? Also it is my first virtual env(distinct from the (base) one), so i probably missing some important concepts.
Fortunately i've found a solution to use pybrain with python3 - i just downloaded it from source !pip install https://github.com/pybrain/pybrain/archive/0.3.3.zip and it works in python 3.8
I just installed alpha_vantage using pip and tried it on IDLE but I'm more used to working on Spyder so when I tried importing it there, I got the No module named 'alpha_vantage'.
I thought the problem was that i used pip instead of conda but when I tried 'conda install alpha_vantage' I got a PackagesNotFoundError: The following packages are not available from current channels: alpha_vantage
I assume that that when you say that you installed it with pip, you mean from your systems default command line.
So, type the following command.
(for windows cmd)
where python
Do the same in spyder. The path output should match if not there is your problem.
(for unix)
which python
First all, to use conda you need: conda activate .
To know conda env name: conda env list
When you stay in env conda : pip install alpha_vantage
Previously when I launched a jupyter-notebook within a conda environment I would have access to the conda environment. I recently started with a clean Anaconda3 (macOS) install and now I can no longer connect to the conda env with jupyter. The issue seems to be related to this issue and this stack-overflow question.
As noted in the comments the question is closely related to this SO question as well. However question is probably closer and none of the answers in either fix my issue.
I would expect after creating and activating a conda env, that either jupyter notebook:
would work out of the box and recognize the environment it was
launched in: this does not happen. the jupyter-notebook doesn't have
access to the modules installed in the new env
or, i would need to
run conda install jupyter in the new environment. the install fails
with ImportError: cannot import name 'ensure_dir_exists'. Note the
traceback does indeed indicate that it is using the correct conda-env
/Users/brook/anaconda3/envs/test2/lib/python3.6/site-packages/notebook/nbextensions.py
I tried the following:
conda update jupyter_core jupyter_client in the base env: this did
not fix any of the problems
conda install jupyter_core jupyter_client
notebook in the new env: these installed correctly but then when i
ran jupyter notebook i got ImportError: cannot import name
'ensure_dir_exists'
conda install nb_conda in the new env but that
also failed with ImportError: cannot import name 'ensure_dir_exists'
conda install nb_conda in the base env: this almost worked - i think.
after launching the notebook the conda tab shows my current env as
the default.
However when creating a notebook i do not see it listed as an option
I thought that since its checked as the default the "Python 3" option would be the current env "test3". However this still didn't work - importing modules give ModuleNotFoundError and double checking at the command line the modules are correctly installed.
Finally. I should note that recently I did a Unix install on a cloud instance and running conda install jupyter in the new env worked as expected.
For those who made it this far, some details:
macOS (10.11.6)
i tried the graphical-installer, also the cmd line install from the most recent version as well as 5.3.1 and 5.2.0
and ...
Thanks!
When I try to import tensorflow in IPython in my Anaconda environment, I get a No module named tensorflow error. However, when I import it after running the python command in the terminal, there are no errors.
I've googled for solutions and so far I have tried the following:
copied the site-packages inside /anaconda2/lib/python2.7/envs/tensorflow/lib/python2.7/site-packages/ to /anaconda2/lib/python2.7/site-packages/
installed ipython in the conda environment with conda install ipython
Anyone know what else I could try?
Refer: Tensorflow and Anaconda on Ubuntu?
I found a link where the tensorflow.whl files were converted to conda packages, so I went ahead and installed it using the command:
conda install -c https://conda.anaconda.org/jjhelmus tensorflow
and it worked, since the $PATH points to anaconda packages, I can import it now!
Source is here