Reputation: 455
Forgive me but I'm new to python. I've installed a package (theano) using
conda install theano
, and when I type conda list
, the package exists
However, when I enter the python interpreter by running python
, and try to import it with import theano
, I get an error: "no module named theano", and when I list all python modules, theano doesn't exist.
What am I missing?
Upvotes: 25
Views: 45435
Reputation: 39
I sorted my case out by accident and just want to provide it look thorough.
when I tried to use the pip to install the 'pygsheets', I met the same problem. I use the anaconda environment. I could see it is already
'Successfully installed' in ' /usr/local/anaconda3/lib/python3.9/site-packages'.
Then when type:
which python
I got
/usr/local/anaconda3/bin/python
Which is not the path that I currently used and not my interpreter path.
So, I changed the the .zshrc file(not bash environment, so it is .zshrc
). But it seems I changed it with wrong codes. /usr/local/anaconda3/bin
is changed to the packages location: /usr/local/anaconda3/lib/python3.9/site-packages
.
Thus, when I source the file, the error encounted:
__add_sys_prefix_to_path:6: command not found: dirname permission denied: /usr/local/anaconda3/lib/python3.9/site-packages
Then I changed it to the original one. After that, which python
returns me the path that I wanted:
/usr/local/anaconda3/envs/xxx/bin/python
Upvotes: 1
Reputation: 351
I had this problem and realised that the issue was that ipython
and jupyter-notebook
did not have the same sys.path
as python
, just in case that helps anyone.
Upvotes: 2
Reputation: 61
When I had this issue my python install was actually missing a "site-packages" path reference. To solve/workaround the issue do the following.
python -c "import site; print(site.getsitepackages())"
Example Output: ['C:\Anaconda3', 'C:\Anaconda3\lib\site-packages']
If you're interested in managing your own "site-packages" locations check out the Python Doc for details on setting up a site config file.
Upvotes: 6
Reputation: 530
I had a base environment where I had installed keras_vggface using conda (sudo pip install git+https://github.com/rcmalli/keras-vggface.git: Courtesy: https://machinelearningmastery.com/how-to-perform-face-recognition-with-vggface2-convolutional-neural-network-in-keras/). Launched anaconda-navigator from base (post conda activate base
), import keras_vggface failed.
When base
is deactivated, and in python command line, import worked fine. which python
reveals the one within anaconda bin directory. Now, I did pip3 install keras_vggface
while being in base
.
Now, I am able to import the module from within base
and in python prompt and also from jupyter notebook launched from base via anaconda-navigator.
Note: this is not an expert advice on how it has to be done; please use this experience with pinch of salt.
Upvotes: 0
Reputation: 91
So I also had the same problem, turn out that I had named my own file to the same modulename (graphviz) and it tried to import that one instead... Took me a while before I figured that one out!
Upvotes: 1
Reputation: 116
Probably due to the fact you have multiply python envs installed in your computer.
when you do which python
you will probably get the native python installed in your computer. that is /usr/bin/python
You want to use the Python that came when you installed Anaconda.
Just add Anaconda path to the beginning of your $PATH
.
(In order to do this you probably need to edit your ~/.bashrc
file (or the equivalent file for your shell) then source ~/.bashrc
.
Next time you will go to will run python
and import theano
you'll succeed.
Upvotes: 7
Reputation: 1585
Do you have another installation of Python on your system? You can run "which python" in your terminal to determine which Python will be used.
Upvotes: 2