'Conda list' shows folium is installed, but cannot "import folium" (anaconda x64)

0

Issue

I have installed folium using command ‘conda install -c ioos folium=0.2.0’

It looks to have installed correctly, and it showing on ‘conda list’ results.

When I run python from cmdline, then attempt an import of folium, i get the following error:

>>>import folium
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named 'folium'

Any ideas about how to fix this?

Solution

I had have the same issue. 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.

Answered By – Andre Araujo

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave A Reply

Your email address will not be published.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More