Skip to content
Advertisement

No module named ‘folium’ after installing via pip

Basically after I have already installed folium with pip (pip install folium) previously the code worked, but suddenly I got this error.

Here is my code:

import pandas as pd
import folium
from geopy.geocoders import ArcGIS

#data frame
snifim_df = pd.read_csv('Snif.csv')
nom = ArcGIS()

snifim_df['LAT'] = snifim_df['Address'].apply(nom.geocode,timeout=15).apply(lambda x:x.latitude)
snifim_df['LON'] = snifim_df['Address'].apply(nom.geocode,timeout=15).apply(lambda x:x.longitude)


Mcmap = folium.Map(location=[32.58, -99.09], zoom_start = 6)
fg = folium.FeatureGroup(name = "McDonalds")

snif_lat = list(snifim_df['LAT'])
snif_lon = list(snifim_df['LON'])
snif_name = list(snifim_df['Name'])
snif_address = List(snifim_df['Address'])

html = """  <h4>Mcdonalds</h4>
            Snif_Adress: %s

"""

for lat,lon,name,add in zip(snif_lat,snif_lon,snif_name,snif_address):
    iframe = folium.Iframe(html = html % str(add),width=200, height=100)
    fg.add_child(folium.Marker(location=[lat,lon],popup=folium.Popup(iframe),icon="glyphicon glyphicon-piggy-bank"))


Mcmap.add_child(fg)
Mcmap.save("test.html")

Advertisement

Answer

2 possibilities come to my mind:

  • the first one, cited by Paul, is that you installed it with pip (for Python 2) and you try using it with Python 3 (so you need to install it with pip3 as cited in Paul’s answer)

  • You have a script file named folium(.py) and you should rename it

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement