繁体   English   中英

在Bluemix中启动Python 3应用程序时出现错误“ ImportError:没有名为请求的模块”

[英]Error “ImportError: No module named request” starting Python 3 app in Bluemix

我试图在Bluemix中启动我的Python 3应用程序,并且一直在说它正在尝试启动。

-----> Uploading droplet (32M)

0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 starting
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 down
0 of 1 instances running, 1 starting

我也在无法找到请求的日志中收到此错误。 有什么想法我做错了吗?

2015-04-17T08:35:50.88-0400 [App/0]   ERR Traceback (most recent call last):
2015-04-17T08:35:50.88-0400 [App/0]   ERR   File "server.py", line 7, in <module>
2015-04-17T08:35:50.88-0400 [App/0]   ERR     from wordnik import *
2015-04-17T08:35:50.88-0400 [App/0]   ERR   File "/app/.heroku/python/lib/python2.7/site-packages/wordnik/swagger.py", line 10, in <module>
2015-04-17T08:35:50.88-0400 [App/0]   ERR     import urllib.request, urllib.error, urllib.parse
2015-04-17T08:35:50.88-0400 [App/0]   ERR ImportError: No module named request
2015-04-17T08:35:50.96-0400 [DEA]     ERR Instance (index 0) failed to start accepting connections

我可以通过显式调用所需的Python版本来解决此问题。 在当前的buildpack中,Bluemix使用Python 2.7.9。

为了找出要使用的Python版本,我在应用程序的根目录中创建了一个名为runtime.txt的文件。 runtime.txt的内容如下:

python-3.4.1

在Bluemix上,类似的Python启动错误的另一个可能原因是缺少requirements.txt依赖项。 Ryan Baxter在他的博客文章Deploying a Python App To BlueMix中阐明了这一点

为了完整起见,他继续指出导致难以理解的错误的其他陷阱,例如(1)Python buildpack级别与Bluemix / Cloud Foundry不兼容,以及(2)应用程序无法从环境变量VCAP_APP_PORT检索端口。用于启动HTTP服务器。 后者的症状是一个在本地运行良好的应用程序,但部署后会崩溃并显示错误"failed to start accepting connections" 如果看到此错误并暂时挠头,不要感到难过; 几乎每个人都在第一次部署时犯了一个错误。

暂无
暂无

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

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