Installed a package with Anaconda, can't import in Python
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.
When I had this issue my python install was actually missing a "site-packages" path reference. To solve/workaround the issue do the following.
- Search for your newly installed package from the Anaconda directory and note the path. (e.g. C:\Anaconda\site-packages)
- Run the following in your terminal:
python -c "import site; print(site.getsitepackages())"
Example Output: ['C:\Anaconda3', 'C:\Anaconda3\lib\site-packages']
- If the path noted in step one is missing from the list then that's your problem. The quick fix is to move the new package to a listed site-packages folder or add the missing path to your PYTHONPATH environment variable.
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.
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.