Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conda list shows a package but cannot import it

Tags:

Here an issue i'm having on a conda Virtual env. I'm using ubuntu 64b guest on windows 7 host with Virtual Box.

So when i'm doing :

source activate MyVirtEnv conda list |grep visdom visdom                    0.1.05                        0    conda-forge 

Seems to be installed right ? Next step :

python Python 3.5.3 |Anaconda custom (64-bit)| (default, Mar  6 2017, 11:58:13)  [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import visdom Traceback (most recent call last):   File "<stdin>", line 1, in <module> ImportError: No module named 'visdom' >>>  

Ok, here i'm lost. Why does python does not recognize this package (and it's not the only one). I'm still in my env activated when executing python.

I'm quite new to python so perhaps i'm missing a huge mistake, please be kind :D

Thanks for your help on this one !

Update 1 :

deeplearning@deep-learning-virtual-machine:~$ source activate universe (universe) deeplearning@deep-learning-virtual-machine:~$ python Python 3.5.3 |Anaconda custom (64-bit)| (default, Mar  6 2017, 11:58:13)  [GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import sys >>> sys.path ['', '/home/deeplearning/anaconda3/envs/universe/lib/python35.zip', '/home/deeplearning/anaconda3/envs/universe/lib/python3.5', '/home/deeplearning/anaconda3/envs/universe/lib/python3.5/plat-linux', '/home/deeplearning/anaconda3/envs/universe/lib/python3.5/lib-dynload', '/home/deeplearning/anaconda3/envs/universe/lib/python3.5/site-packages', '/home/deeplearning/anaconda3/envs/universe/lib/python3.5/site-packages/Sphinx-1.5.6-py3.5.egg', '/home/deeplearning/gym', '/home/deeplearning/anaconda3/envs/universe/lib/python3.5/site-packages/torchvision-0.1.9-py3.5.egg'] >>> sys.executable '/home/deeplearning/anaconda3/envs/universe/bin/python' >>>  
like image 855
Damien F Avatar asked Oct 16 '17 09:10

Damien F


People also ask

What is the difference between conda list and pip list?

The fundamental difference between pip and Conda packaging is what they put in packages. Pip packages are Python libraries like NumPy or matplotlib . Conda packages include Python libraries (NumPy or matplotlib ), C libraries ( libjpeg ), and executables (like C compilers, and even the Python interpreter itself).

How do you resolve conflicts in conda?

Recommendations for Avoiding Dependency Conflicts with CondaAlways create a new environment for each project. Install all the packages that you need in the new environment at the same time. Installing packages one at a time can lead to dependency conflicts.


1 Answers

A couple possibilities occur to me:

1. A Potential Path Problem

Your python command might refer to a different python than the python which is in your active conda environment folder. Check this by running in terminal which conda and which python. If you get something like the below, you're good here.

/anaconda3/bin/conda /anaconda3/envs/<yourEnvName>/bin/python 

If you are getting different paths, it is possible your path is messed up. open up your .bashrc file and double check lines associated with python and conda.

Alternatively, reinstall conda.

2. A Very Vexing Version Variation

You might have a version/dependency incompatibility issue. This seems unlikely to me as visdom is compatible with python 2.7 onward (I think) and you clearly are using python 3.5.2. Nonetheless, this might happen if you are using multiple package managers. Nowadays it is less common, but it does happen occasionally. Try checking this by running pip show visdom and/or conda search --reverse-dependency visdom or the equivalent for your package manager.

If this is indeed a problem, then I suggest first updating your packages and if that does not work then uninstalling visdom with the original package manager and trying to install with a different package manager.


If all of the above fails, start exploring your problem from a new environment. Can you replicate it in the new environment? (I can't). Can you replicate it on another machine? etc...

Keep the internets updated with your problem as we might be able to help some others out!

like image 161
Joe B Avatar answered Sep 30 '22 19:09

Joe B