简体   繁体   中英

ModuleNotFoundError: No module named 'googlemaps' - though googlemaps installed

I am running an app.py which imports googlemaps as

import googlemaps

But when I do a pip list, it lists googlemaps as

googlemaps      3.0.2

When I run the app,

Traceback (most recent call last):


File "app.py", line 40, in <module>
    import googlemaps
ModuleNotFoundError: No module named 'googlemaps'

I am on Windows, Python 3.6.0

In order to be sure. that pip and your script use the same python version I suggest to call following commands from the same terminal window.

python3 -m pip freeze | grep -i googlemaps
python3 -c "import sys ; print(sys.exewutable)"
python3 -c "import sys ; print("\n".join(sys.path))"

Try even following line to prove that googlemaps is installed if not being called from your app

python3 -c "import googlemaps"

and

python3 app.py

If you do not call your app directly with python, then tell us how you start the app. This different way of calling might be why it is not pointing to the same python version / virtualenv than the one where you installed googlemaps

If you do not know how the app is exactly started (eg started by a web server or similar), then I suggest you add following lines to app.py before the import line that fails.

import os, sys
# the next two l
with open(os.expanduser("~/debug.txt", "w") as fout:
    fout.write("EXE: %s\n" % sys.executable)
    fout.write("PATH:\n" + ("\n".join(sys.path)))

This should create a file named debug.txt , that you can inspect

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM