简体   繁体   English

Google App Engine ImportError:未命名模块

[英]Google App Engine ImportError: No module named

I am creating a Python Web App in Google App engine. 我正在Google App引擎中创建一个Python Web App。 When I 当我

sudo pip install sudo pip安装

a third party library and then try to import it, I get the error 'ImportError: No module named x'. 第三方库,然后尝试将其导入,出现错误“ ImportError:没有名为x的模块”。 Where x is the name of that library. 其中x是该库的名称。 In my case as an example: Boto, Boto3, Fask etc. 以我为例:Boto,Boto3,Fask等。

If I go into shell in GAE and type python >> import X the library can be used inside the python environment. 如果我在GAE中进入shell并键入python >> import X,则可以在python环境中使用该库。 When deploying the app though or running the app in the virtaul server in Google App Engine I get the module import error. 在部署应用程序或在Google App Engine的virtaul服务器中运行应用程序时,出现模块导入错误。

  • I even tried methods like: python >> import sys >> sys.path.insert(0, "path_here") 我什至尝试了以下方法:python >> import sys >> sys.path.insert(0,“ path_here”)
  • export PYTHONPATH and selected where those libraries are located 导出PYTHONPATH并选择这些库所在的位置

I even followed several Q&A here in Stackoverflow without any success, can somebody please give me a proper way to fix the import error in Google App Engine? 我什至在Stackoverflow上都遵循了一些问答,但没有成功,有人可以给我适当的方法来修复Google App Engine中的导入错误吗?

FYI FYI

  • I am not using any local environment in my pc, I am working directly through the GAE bash console, the launch code editor in GAE and I am running the command dev_appserver.py $PWD 我没有在PC中使用任何本地环境,而是直接通过GAE bash控制台,GAE中的启动代码编辑器进行工作,并且正在运行命令dev_appserver.py $ PWD
  • When I do 当我做

pip freeze 点冻结

I can see that the modules are currently installed and deployed on the GAE virtual environment. 我可以看到这些模块当前已安装和部署在GAE虚拟环境上。 Is there a problem with my path? 我的路线有问题吗? What's the best approach to make GAE load my already installed third party libraries. 什么是使GAE加载已安装的第三方库的最佳方法?

UPDATE: Importing the library directly on the python shell from Google App Engine works just fine. 更新:从Google App Engine直接在python shell上导入库就可以了。 Importing the library on my python app index.py file results in the error. 在我的python应用程序index.py文件上导入库会导致错误。 Python import directly from Shell Python import to the index.py file Python直接从Shell 导入Python导入到index.py文件

Though this is an old thread, adding this answer now: 虽然这是一个旧线程,但现在添加以下答案:

Run command : gcloud components list 运行命令:gcloud组件列表

This will show the different components installed and not in your environment. 这将显示已安装的不同组件,而不是您的环境中的组件。

Install app-engine-python components if not installed: 如果未安装,请安装app-engine-python组件:

gcloud components install app-engine-python gcloud组件安装app-engine-python

gcloud components install app-engine-python-extras gcloud组件安装app-engine-python-extras

If it doesn't work: 如果不起作用:

In Windows, uninstall and download and install Google-sdk (check the python version you need). 在Windows中,卸载并下载并安装Google-sdk(检查所需的python版本)。 Delete all the files the installer ask you to delete in the last step and run the gcloud component commands again. 删除安装程序在最后一步要求您删除的所有文件,然后再次运行gcloud组件命令。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ImportError:谷歌应用引擎中没有名为****的模块错误 - ImportError: No module named **** Error in google app engine ImportError:在Google App Engine上没有名为flask的模块 - ImportError: No module named flask on google app engine Google App Engine-ImportError:没有名为edf的模块 - Google App Engine - ImportError: No module named edf 谷歌应用引擎中的“导入错误:没有名为装饰器的模块” - 'ImportError: No module named decorator' in google app engine Google App Engine启动器(Python)-ImportError:没有名为webapp2的模块 - Google App Engine Launcher (Python) - ImportError: No module named webapp2 Python ImportError:Google app引擎项目中没有名为main的模块 - Python ImportError: No module named main in Google app engine project importError:没有名为Coreapp的模块(Flask和Google App Engine) - importError: No module named Coreapp (Flask and Google App Engine) Google App Engine:导入错误:没有名为 pkg_resources 的模块 - Google App Engine: ImportError: No module named pkg_resources 转到Google App Engine教程:ImportError:没有名为_md5的模块 - Go tutorial for Google App Engine: ImportError: No module named _md5 Google App Engine:ImportError:没有名为appengine.ext的模块 - Google App Engine: ImportError: No module named appengine.ext
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM