Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 部署Watson视觉识别应用程序失败_Python_Ibm Cloud_Watson_Visual Recognition - Fatal编程技术网

Python 部署Watson视觉识别应用程序失败

Python 部署Watson视觉识别应用程序失败,python,ibm-cloud,watson,visual-recognition,Python,Ibm Cloud,Watson,Visual Recognition,我在本地创建了一些自定义分类器,然后尝试在bluemix上部署一个应用程序,根据我制作的分类器对图像进行分类 当我尝试部署它时,它无法启动 import os import json from os.path import join, dirname from os import environ from watson_developer_cloud import VisualRecognitionV3 import time start_time = time.time() visual_

我在本地创建了一些自定义分类器,然后尝试在bluemix上部署一个应用程序,根据我制作的分类器对图像进行分类

当我尝试部署它时,它无法启动

import os
import json
from os.path import join, dirname
from os import environ
from watson_developer_cloud import VisualRecognitionV3 
import time
start_time = time.time()

visual_recognition = VisualRecognitionV3(VisualRecognitionV3.latest_version, api_key='*************')

with open(join(dirname(__file__), './test170.jpg'), 'rb') as image_file:
 print(json.dumps(visual_recognition.classify(images_file=image_file,threshold=0, classifier_ids=['Angle_971786581']), indent=2))

print("--- %s seconds ---" % (time.time() - start_time))
即使我尝试部署一个简单的打印,它也无法部署,但我从bluemix获得的入门应用程序,或者我发现在线部署的Flask教程()都很好

我对网络编程和使用云服务非常陌生,所以我完全迷路了


谢谢。

Bluemix希望您的python应用程序能够在一个端口上运行。如果应用程序没有在端口上提供某种响应,则假定应用程序启动失败

# On Bluemix, get the port number from the environment variable PORT
# When running this app on the local machine, default the port to 8080
port = int(os.getenv('PORT', 8080))


@app.route('/')
def hello_world():
    return 'Hello World! I am running on port ' + str(port)

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=port)
看起来您编写的代码只是执行一次并停止。相反,让它在有人点击你的URL时工作,如上面的hello_world()函数所示

想想当有人进入你的应用程序\u NAME.mybluemix.net时,你希望发生什么

如果不希望应用程序是WEB应用程序,而只执行一次(后台工作程序应用程序),则在cf push命令末尾使用--no route选项。然后,使用
cf logs appname--recent查看日志,以查看应用程序的输出


Bluemix希望您的python应用程序在端口上运行。如果应用程序没有在端口上提供某种响应,则假定应用程序启动失败

# On Bluemix, get the port number from the environment variable PORT
# When running this app on the local machine, default the port to 8080
port = int(os.getenv('PORT', 8080))


@app.route('/')
def hello_world():
    return 'Hello World! I am running on port ' + str(port)

if __name__ == '__main__':
    app.run(host='0.0.0.0', port=port)
看起来您编写的代码只是执行一次并停止。相反,让它在有人点击你的URL时工作,如上面的hello_world()函数所示

想想当有人进入你的应用程序\u NAME.mybluemix.net时,你希望发生什么

如果不希望应用程序是WEB应用程序,而只执行一次(后台工作程序应用程序),则在cf push命令末尾使用--no route选项。然后,使用
cf logs appname--recent查看日志,以查看应用程序的输出


主要问题是watson developer云模块,给了我一个找不到的错误

我降级到python版本2.7.12,为所有用户安装它。 修改了runtime.exe和requirements.txt(可能不需要requirements.txt) 与Diego一起暂存,使用“无路由”和“设置健康检查应用程序名称”“无”命令


这些解决了问题,但我仍然获得退出状态0。

主要问题是watson developer云模块,给我一个无法找到的错误

我降级到python版本2.7.12,为所有用户安装它。 修改了runtime.exe和requirements.txt(可能不需要requirements.txt) 与Diego一起暂存,使用“无路由”和“设置健康检查应用程序名称”“无”命令


这些解决了问题,但我仍然获得退出状态0。

当你在bluemix中部署应用程序时,你应该有一个requirements.txt,其中包括你在应用程序中使用的服务。 所以,你应该检查一下你的requirements.txt,也许你输了

watson_developer_cloud
然后,requirements.txt如下所示:

Flask==0.10.1
watson_developer_cloud

在bluemix中部署应用程序时,应该有一个requirements.txt,其中包含应用程序中使用的服务。 所以,你应该检查一下你的requirements.txt,也许你输了

watson_developer_cloud
然后,requirements.txt如下所示:

Flask==0.10.1
watson_developer_cloud

你需要排除你的代码。试着在本地运行代码,看看是否可以先运行。否则这更像是Bluemix应用程序的问题,在这种情况下,您可能需要发布与错误相关的日志。@SimonO'Doherty我的代码在本地运行得很好。当我尝试部署时,我无法从post日志中获得任何有用的信息,只是应用程序崩溃了。顺便说一下,我从平台内的选项获取日志,因为cf logs appname--recent给了我一个错误。您需要排除代码。试着在本地运行代码,看看是否可以先运行。否则这更像是Bluemix应用程序的问题,在这种情况下,您可能需要发布与错误相关的日志。@SimonO'Doherty我的代码在本地运行得很好。当我尝试部署时,我无法从post日志中获得任何有用的信息,只是应用程序崩溃了。顺便说一句,我从平台内的选项获取日志,因为cf logs appname--recent给了我一个错误。我已经尝试使用--no route运行,但没有成功,但我将按照链接中的说明重试。谢谢。请注意,
VCAP\u APP\u PORT
环境变量的使用已被弃用,在Cloud Foundry的未来版本中无法使用,您应该改用
PORT
。我已经尝试使用--no route运行,但没有成功,但我将按照链接中的说明重试。谢谢。请注意,
VCAP\u APP\u PORT
环境变量的使用已被弃用,在Cloud Foundry的未来版本中不起作用,您应该改用
PORT