0

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")
Diego
  • 216
  • 1
  • 11
michox2
  • 113
  • 11
  • What `pip show folium` gives you? – emremrah Jan 10 '20 at 17:23
  • 1
    you can always use `python -m pip install ...` to run `pip` with `python` which you use to run code. The same with `python -m pip list` to check if `folium` is installed for `python` which you use to run code. – furas Jan 10 '20 at 18:12
  • Does this answer your question? [Python module install with pip](https://stackoverflow.com/questions/59638964/python-module-install-with-pip). Edit: The linked question is actually marked as dupe now, so that's probably the better flag – C.Nivs Jan 10 '20 at 18:12

3 Answers3

2

Shooting in the dark here....

try:

pip3 install folium

It may be that it is installed for python 2.7 but not 3.x

Paul Lemmons
  • 112
  • 3
2

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

FoxYou
  • 120
  • 1
  • 11
0

python3 -m pip install <package_name>

This ensures that you're installing the package in the python version you're using.

Siddharth Prajosh
  • 1,013
  • 2
  • 9
  • 16