Reputation: 638
I get an ImportError with startup script for Google Cloud Compute. I believe there is something wrong with permissions and/or SSH. My program runs fine from the SSH console. In the start-up script, it gets an import error. I've tried putting the full path, partial path etc. This is the debug output. My startup script is cd, then python path/to/file.py. Ubuntu 1604 xenial v20190212.
startup-script: INFO Starting startup scripts.
startup-script: INFO Found startup-script in metadata.
startup-script: INFO startup-script: Traceback (most recent call last):
startup-script: INFO startup-script: File "Project/analyzePDFs.py", line 6, in <module>
startup-script: INFO startup-script: from _mongoWrite import w_db, r_db, f_db
startup-script: INFO startup-script: File "/home/davidxmkong/Project/_mongoWrite.py", line 1, in <module>
startup-script: INFO startup-script: from pymongo import MongoClient, UpdateOne, InsertOne
startup-script: INFO startup-script: ImportError: No module named pymongo
startup-script: INFO startup-script: Return code 1.
startup-script: INFO Finished running startup scripts.
Upvotes: 0
Views: 521
Reputation: 11
Ran into a similar issue where my startup script was pretty much only
python3 myscriptname
The issue was that when the startup script ran python3, it referenced a different installation of python3 than the one I installed all my modules on. So I qualified the python3 (in my case /opt/conda/bin/python3) and the ImportErrors went away.
Upvotes: 1
Reputation: 638
The solution was to install all the dependencies on the root. So I did sudo su, then reinstalled python, etc.
Upvotes: 2