Python Forum

Full Version: Folium import error
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hello I am trying to use folium library but it is not working for me. I have tried with python 2.7/3.6/3.9. Below is my code.

import folium

# Create map object
m = folium.Map(location=[42.3601, -71.0589], zoom_start=12)

# Create markers
folium.Marker([24.943304651124997, 67.10031915579981],
              popup='<strong>Kashif Home</strong>',
              tooltip=tooltip).add_to(m)

# Generate map
m.save('mapnew.html')
Here is my error message- I have installed requests
Error:
(pythonProject1) C:\Users\kashif.raza\PycharmProjects\pythonProject1>python map.py Traceback (most recent call last): File "map.py", line 1, in <module> import folium File "C:\Users\kashif.raza\.conda\envs\pythonProject1\lib\site-packages\folium\__init__.py", line 8, in <module> import branca File "C:\Users\kashif.raza\.conda\envs\pythonProject1\lib\site-packages\branca\__init__.py", line 1, in <module> import branca.colormap as colormap File "C:\Users\kashif.raza\.conda\envs\pythonProject1\lib\site-packages\branca\colormap.py", line 15, in <module> from branca.element import ENV, Figure, JavascriptLink, MacroElement File "C:\Users\kashif.raza\.conda\envs\pythonProject1\lib\site-packages\branca\element.py", line 13, in <module> from urllib.request import urlopen ImportError: No module named request
it's not asking for requests. it complains about urllib.request
which version of python do you use? it looks like you are using python2
You mention you've tried this with python3, but that particular error message is what I'd expect with python2 and that module tries to load..

$ python3 -c "import urllib.request;print('ok')"
ok
$ python2 -c "import urllib.request;print('ok')"
Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named request