我收到带有 Google Cloud Compute 启动脚本的 ImportError。我相信权限和/或 SSH 有问题。我的程序在 SSH 控制台上运行良好。在启动脚本中,它得到一个导入错误。我试过放置完整路径、部分路径等。这是调试输出。我的启动脚本是cd,然后是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_dbstartup-script: INFO startup-script: File "/home/davidxmkong/Project/_mongoWrite.py", line 1, in <module>startup-script: INFO startup-script: from pymongo import MongoClient, UpdateOne, InsertOnestartup-script: INFO startup-script: ImportError: No module named pymongostartup-script: INFO startup-script: Return code 1.startup-script: INFO Finished running startup scripts.
2 回答
慕田峪9158850
TA贡献1794条经验 获得超8个赞
遇到了一个类似的问题,我的启动脚本几乎只有
python3 myscriptname
问题是,当启动脚本运行 python3 时,它引用的 python3 安装与我安装所有模块的安装不同。所以我限定了python3(在我的例子中是/opt/conda/bin/python3)并且ImportErrors消失了。
添加回答
举报
0/150
提交
取消
