ModuleNotFoundError: No module named 'googlemaps'
Change from googlemaps import *
to import googlemaps
What from googlemaps import *
does is that it imports all the contents of the googlemaps
module. import googlemaps
imports the whole googlemaps
module as a whole.
Related videos on Youtube
Ben.W
Updated on June 04, 2022Comments
-
Ben.W almost 2 years
I am a newcomer to Django python programming. Now I am working on the server side. I want to use google maps API, my view.py is like this:
from django.shortcuts import render from django.shortcuts import HttpResponse from googlemaps import * # Create your views gmaps = googlemaps.Client(key='A') def index(request): if request.method=="GET": geocode_result = gmaps.geocode('1600 Amphitheatre Parkway, Mountain View, CA') return geocode_result
Also, I have already installed 'googlemaps' using pip. And when I import it in IDE, nothing goes wrong. But when I want to start the server to test the code, the server won't run and tells me ModuleNotFoundError: No module named 'googlemaps', I am confused that I have already downloaded it and added it in settings.py, importing in IDE also seems fine. But where I did wrong makes it fail to start the server?
-
thyago stall about 6 yearsAre you using virtualenv or something like that? It seems you are not serving on the same environment you installed the library
-
Ben.W about 6 yearsI am not using that, is the environment of anaconda and python itself like virtualenv?
-
-
Ben.W about 6 yearsThat don't work so I changed to import *, also won't work
-
Ben.W about 6 yearsThank you for answering, but I have just tried, now, I can't even import googlemaps. I am using Visual studio, and it tells me that it can't analyze 'googlemaps', the IntelliSense may be lost. But sometimes, it can be imported correctly, but finally, when I want to start server, the result is the same.
-
Cale Sweeney about 5 years@ParthSharma What does
googlecode
have to do with thegooglemaps
module?