8

I am trying to import folium into a Jupyter notebook I'm working on and I cannot seem to solve the import issues with the Folium library. Has anyone else solved this problem?

!pip install folium
import pandas as pd
import folium

Output from the above yields:

`ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-7-a9938c267a0c> in <module>()
      1 get_ipython().system('pip install folium')
      2 import pandas as pd
----> 3 import folium

ModuleNotFoundError: No module named 'folium'`
Tyler Russell
  • 653
  • 3
  • 10
  • 26

14 Answers14

12

It is not available via default conda channel. Try using conda-forge channel to install folium as show below:

conda install -c conda-forge folium
ssp
  • 141
  • 1
  • 4
5

From the source:

  • Choose the sandbox folder of your choice (~/sandbox for example)

    $ mkdir visualization
    $ cd visualization
    
  • Clone folium from github:

    $ git clone https://github.com/python-visualization/folium
    
  • Run the installation script

    $ cd folium
    $ python setup.py install
    
sentence
  • 8,213
  • 4
  • 31
  • 40
Susma
  • 76
  • 1
  • 4
5

I solved the same problem by executing following command

python3 -m pip install folium
Prem Ukkoji
  • 91
  • 1
  • 2
2

I had similar issues as the original problem. I installed successfully from the shell but jupyter would not recognize the module.

What worked for me was (in the jupyter notebook):

!pip install folium
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
m_leighty
  • 21
  • 1
  • In modern Jupyter, this is better as `%pip install folium`. See [here](https://discourse.jupyter.org/t/why-users-can-install-modules-from-pip-but-not-from-conda/10722/4?u=fomightez) about the modern magic install commands that insure installation occurs in the environment backing the kernel underlying the active notebook. – Wayne Mar 27 '23 at 15:52
2

My method was:

$ cd C:\programdata\anaconda3\lib\site_packages

Then

git clone https://github.com/python-visualization/folium.git
git clone https://github.com/pallets/jinja.git 

I imported Folium then it worked.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
1

I eventually git-cloned the github repositories for folium and jinja2 into a file and it worked.

Specifically, on my computer, I changed into the right directory from the command line interface with:

$ cd C:\programdata\anaconda3\lib\site_packages

And then typed:

git clone https://github.com/python-visualization/folium.git
git clone https://github.com/pallets/jinja.git

Then import folium (from within python) worked.

Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
ken
  • 61
  • 1
  • 7
1

I had the same problem while installing with pip3 (macOS with python3).

Manually cloning the github repo solved it.

  • Move to the package folder of python 3
    cd /usr/local/lib/python3.6/site-packages/  
    
  • Then
    git clone https://github.com/python-visualization/folium  
    cd folium  
    python setup.py install  
    
Gino Mempin
  • 25,369
  • 29
  • 96
  • 135
1

So for Mac OS with Python 3.x, Anaconda doesn't have the library on its installer by default. You need to clone and manually install 2 two libraries:

1) Navigate to /Users/<username>/anaconda3/lib/python3.6/site-packages

2)Folium

git clone https://github.com/python-visualization/folium.git

cd folium

python setup.py install

3)Branca (This library is a spinoff from folium, that would host the non-map-specific features, if importing folium without branca the kernel complains about missing module named branca)

git clone https://github.com/python-visualization/branca.git

cd branca

python setup.py install

4)Restart your kernel

5)Import

import folium

import branca

Abhimanyu
  • 1,188
  • 8
  • 11
1

Running the following code in the terminal fixed it for me.

$ conda install folium -c conda-forge
Eddie Lam
  • 579
  • 1
  • 5
  • 22
0

Below mentioned command execute in your root working environment.

Solution 1:

pip install folium

or

pip3 install folium

Solution 2:

conda install branca
conda install folium
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
Susma
  • 76
  • 1
  • 4
0

Make sure to reinstall jupyter in new conda env. From what I was able to tell, it runs the Jupyter from preexisting environments and that jupyter does not have access to the packages of the new environment

dmbhatti
  • 314
  • 2
  • 11
0

I am using windows 10. I was getting same issue. This is how I fixed it.

Open Command prompt, run as administrator.

type "python" to check if python is installed, if not install python globally.

if python is installed, you will see python prompt, Ctrl+Z to exit and Run :

python -m pip install folium
user3444999
  • 481
  • 4
  • 10
0

For osx-64 v0.4.0 the following code worked for me:

Install folium using:

conda install -c conda-forge/label/cf201901 folium

Then verify if the package has been installed

import folium
print('Folium installed and imported!')
Mohnish
  • 1,010
  • 1
  • 12
  • 20
Rimma
  • 1
0

Nothing in this thread didn't work for me. So my solution was a little bit strange. I am using a PyCharm, and in my project dir I have a requirements.txt file. PyCharm understands that libraties in this file must be installed, and if they are not, it can install by itself. So I just wrote "folium==0.12.1" in this file and PyCharm done all the work. Maybe another IDE also can do it.