Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Package installed by Conda, Python cannot find it

I try to install Theano by Anaconda. It works, but when I enter the python -i, import theano shows No module named 'theano'. Do I need to switch another interpreter of Python, how? Also, for the packages installed by conda, if I don't double install them, can I find in Python? How is Python related to Python by Anaconda? Thanks!!!

like image 740
StephanieCoding Avatar asked Oct 01 '16 22:10

StephanieCoding


People also ask

Where are Python packages installed conda?

Conda installs packages into the anaconda/pkgs directory. If conda cannot find the file, try using an absolute path name instead of a relative path name. Installing packages directly from the file does not resolve dependencies.

Where is my python package?

When a package is installed globally, it's made available to all users that log into the system. Typically, that means Python and all packages will get installed to a directory under /usr/local/bin/ for a Unix-based system, or \Program Files\ for Windows.

How do I know if a conda package is installed?

To test your installation, in your Terminal window or Anaconda Prompt, run the command conda list . For a successful installation, a list of installed packages appears.


1 Answers

I had have a similar issue, trying to install folium. If you are using the Anaconda:

When you install using conda install -c conda-forge folium, the package will be placed in:

./anaconda3/envs/[name env]/lib/python3.7/site-packages/folium

When you install using pip (with a anaconda env activated), pip install folium, the package will be placed in:

./anaconda3/lib/python3.7/site-packages/folium

Python use first the sites-packages as the target directory of manually built python packages. When you build and install python packages from source (using distutils, probably by executing python setup.py install ), you will find the installed modules in site-packages by default.

In this case you have two places: /anaconda3/lib/python3.7/site-packages/ and /anaconda3/envs/[name env]/lib/python3.7/site-packages/.

First the modules will be available as default in /anaconda3/lib/python3.7/site-packages/. Sometimes (and I really don't know why) the modules inside sites-packages conda env are not available to import automatically without export the PATH.

So, to solve this issue, you have 2 options:

  • Installing using pip install folium and import folium (don't need install by conda install), or

  • After conda install , run conda init, close the terminal and open a new one. So, try to import again.

Here are some tips about use a pip in a conda-environment.

like image 131
Andre Araujo Avatar answered Oct 08 '22 22:10

Andre Araujo