Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
376 views
in Technique[技术] by (71.8m points)

python - Conda list shows a package but cannot import it

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'
>>> 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...