Python 3.6 Module cannot be found: Folium
Asked Answered
K

14

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'`
Katharinekatharsis answered 18/6, 2017 at 16:33 Comment(8)
did you install folium first??Hankins
Yes. I tried installing outside Jupyter and from within Jupyter. I also tried installing using a conda install.Katharinekatharsis
just type pip install folium in cmd or terminalHankins
I used pip install folium and it works without problem. Then I get the output per my original question above.Katharinekatharsis
Are you using a virtualenv?Subgroup
No, just a notebook from the default environment.Katharinekatharsis
Very strange. If you do import os then os.path, do you get that default environment?Henshaw
Try pip3 install folium or easy_install foliumPeba
B
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
    
Baran answered 19/8, 2017 at 11:34 Comment(0)
B
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
Bookrack answered 31/10, 2018 at 19:24 Comment(0)
B
6

I solved the same problem by executing following command

python3 -m pip install folium
Basilio answered 21/10, 2017 at 16:20 Comment(0)
B
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
    
Baran answered 19/8, 2017 at 11:34 Comment(0)
P
3

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
Possible answered 5/11, 2018 at 3:41 Comment(1)
In modern Jupyter, this is better as %pip install folium. See here about the modern magic install commands that insure installation occurs in the environment backing the kernel underlying the active notebook.Cabbageworm
I
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.

Indiraindirect answered 25/6, 2020 at 17:18 Comment(0)
R
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.

Royal answered 25/9, 2017 at 0:21 Comment(0)
S
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  
    
Scriptorium answered 14/11, 2017 at 18:11 Comment(0)
L
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

Lauer answered 25/2, 2019 at 19:57 Comment(0)
S
1

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

$ conda install folium -c conda-forge
Spokane answered 25/6, 2020 at 17:10 Comment(0)
B
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
Baran answered 19/8, 2017 at 11:25 Comment(0)
A
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

Archeology answered 18/2, 2019 at 13:46 Comment(0)
R
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
Ringnecked answered 26/5, 2019 at 15:46 Comment(0)
M
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!')
Meson answered 23/12, 2020 at 15:18 Comment(0)
P
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.

Palma answered 25/1, 2021 at 13:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.