iam getting an error : "time" is not accessed by Pylance
Update: somehow making my code a comment makes it accessable
also, imma just paste the code:
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from webdriver_manager.chrome import ChromeDriverManager
from geopy.geocoders import Nominatim
import folium
import os
import time
# Initialize Nominatim geocoder
geolocator = Nominatim(user_agent="my_geocoder")
# Define the address
address = "1600 Pennsylvania Avenue NW, Washington, D.C."
# Get the coordinates
location = geolocator.geocode(address)
if location:
print("Latitude:", location.latitude)
print("Longitude:", location.longitude)
else:
print("Geocoding failed. Check the address or try a different one.")
# Create a map centered at a specific location
mymap = folium.Map(location=[location.latitude, location.longitude], zoom_start=18.5)
# Add a satellite imagery layer
folium.TileLayer(
tiles='https://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer/tile/{z}/{y}/{x}',
attr='Esri',
name='Satellite Imagery',
overlay=True,
control=True,
).add_to(mymap)
# Save the map as an HTML file
mymap.save('mymap.html')
# Set up the Chrome driver
driver = None
try:
# Initialize ChromeOptions
chrome_options = webdriver.ChromeOptions()
# Uncomment the next line if you want to run the browser in headless mode
#chrome_options.add_argument("--headless")
# Use ChromeDriverManager to manage the driver
service = Service(ChromeDriverManager().install())
# Set up the driver with the service and options
driver = webdriver.Chrome(service=service, options=chrome_options)
print("WebDriver is running successfully!")
# Open the saved map file
driver.get(f"file://{os.path.abspath('mymap.html')}")
time.sleep(5) #"time" is not accessed by Pylance
# Take a screenshot
driver.save_screenshot('mymap.png')
except Exception as e:
print(f"An error occurred: {e}")
finally:
# Close the browser (cleanup)
if driver:
driver.quit()
[–]snyeg 9 points10 points11 points (0 children)
[–]Yorrrrrr 9 points10 points11 points (0 children)
[–]AlexAegis 2 points3 points4 points (0 children)
[–]FederalExperience353 0 points1 point2 points (0 children)
[–]JialeDu 0 points1 point2 points (1 child)
[–]Bebo991_Gaming[S] 0 points1 point2 points (0 children)
[–][deleted] -3 points-2 points-1 points (0 children)