ModuleNotFoundError: No module named 'googlemaps' where googlemaps only works for the first code execution after atom startup

Asked 2 years ago, Updated 2 years ago, 499 views

environment (simple)
os is mac, editor is atom, language is python, code execution is atom-runner

what someone is doing
Importing googlemaps into python and using google's Geocoding API trying to get latitude and longitude from the address.

problem
The code works fine and you can get the information you want from googlemaps.
However, it only works with the first code execution after atom is started.
For some reason, code execution after the second time will fail with an error.
After the first code execution is complete, the following error will appear when the code is re-executed.

Traceback (most recent call last):
  File"/************/test_geocode.py", line 1, in <module>
    import googlemaps
ModuleNotFoundError: No module named 'googlemaps'

After that, no matter how many times you try, you will only get the same error above.
However, you can restart atom and retrieve information only during the first run.

Code Affected

import googlemaps

googleapikey='My API_KEY'
gmaps=googlemaps.Client(key=googleapikey)

result=gmaps.geocode('Any Address')
lat=result[0]["geometry"]["location"]["lat"]
lng=result[0]["geometry"]["location"]["lng"]
print(result)
print(lat,lng)

The code should be correct as described in the "Problem" section above

Tried

  • When I ran this code with an app called Pythonista on my iPad, I was able to run it as many times as I wanted and get information without any problems
     →The code should be correct.
  • pip install wheel (I tried it because there was information on the Internet, but it didn't change)
  • pip uninstall googlemaps and
    running easy_install googlemaps (There was information in stack over run, so I tried it.Results unchanged)
  • atom Restart
  • Restarting the PC

I found information about the same error (No module named 'googlemaps'), but I couldn't find information about the same symptom.

Environment Details

  • PC:macbookpro macOS Catalina 10.15.6
  • editors:atom1.50.0
  • Code execution: atom-runner 2.7.1
  • python 3.8.5
  • pip20.2.2
  • pyenv1.2.20
  • Googlemaps 4.42

python google-maps google-api atom-editor pip

2022-09-30 21:53

1 Answers

The cause was an atom-runner in the package used to execute code.

I changed the code execution package from atom-runner to script and it was resolved.
atom-runner had to be uninstalled.
If atom-runner is still installed, script will experience the same symptom.
(The reason is unknown)

https://qiita.com/akira_ak/questions/a44579fe3b6201cabfba#answer-c647db82f30ff02a7c22


2022-09-30 21:53

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.