Reputation: 157
I'm using Folium
to create a map and display it as an HTML file. I created a function to open up the HTML file with the given path.
import webbrowser
import folium
from folium import plugins
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from IPython.core.display import display, HTML
m = folium.Map([52.5, 2], zoom_start=5.5)
display(m)
m.save('map.html')
def auto_open(path):
html_page = f'{path}'
m.save(html_page)
# open in browser.
new = 2
webbrowser.open(html_page, new=new)
auto_open('C:\Users\Student\PycharmProjects\World Map')
I'm getting the error code:
auto_open('C:\Users\Student\PycharmProjects\World Map') ^ SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape
It's the correct path to the html file. But I'm not understanding the error at all. I would love the help. Any more information I can give let me know. Thank you.
Edit: I added in the \\
to fix the error, but now I'm getting, I've done this and it pops up:
File "C:\Python\Python37\lib\site-packages\branca\element.py", line 161, in save fid = open(outfile, 'wb') PermissionError: [Errno 13] Permission denied:'C:\\Users\\Student\\PycharmProjects\\World Map'
Upvotes: 0
Views: 143
Reputation: 65278
You need nothing but doubled parentheses to replace the single ones :
auto_open('C:\\Users\\Student\\PycharmProjects\\World Map')
P.S: Don't forget to close up the target file(outfile) before re-run in order not to prevent getting [Errno 13]
Upvotes: 2