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

2024-06-03 09:27:38 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图在Bluemix中启动python3应用程序,但它一直在说它正在尝试启动。在

-----> 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

我也在日志中得到这个错误,关于找不到请求。你知道我做错了什么吗?在

^{pr2}$

Tags: ofinstances应用程序错误runningpython3downstarting
2条回答

Bluemix上Python类似启动错误的另一个可能原因是requirements.txt中缺少依赖项。瑞安·巴克斯特在他的博客文章Deploying A Python App To BlueMix中详细说明了这一点。在

为了完整起见,他接着指出了其他导致难以理解的错误的问题,比如(1)Python buildpack级别与Bluemix/cloudfoundry不兼容,(2)应用程序无法从环境变量VCAP_APP_PORT中检索端口以启动HTTP服务器。后者的症状是一个在本地运行得很好的应用程序,但是一旦部署,就会崩溃并出现错误"failed to start accepting connections"。如果您看到这个错误并抓伤您的头一段时间,不要感到难过;这是几乎每个人在第一次部署时都会犯的错误。在

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

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

python-3.4.1

相关问题 更多 >