我正在研究java Web应用程序,我试图使用简单的AI算法 - NLP来解析文本。 我想从我的应用程序NLP.py运行一个python脚本,它使用驻留在我本地电脑上的另一个文件(3 Gb大小)中的数据,我下载了python插件,然后运行这样的脚本:
String pythonScriptPath = "MY-PATH\\NLP\\NLP.py";
String[] cmd = new String[3];
cmd[0] = "python"; // check version of installed python: python -V
cmd[1] = pythonScriptPath;
cmd[2]="playing sport";
// create runtime to execute external command
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(cmd);
文件层次结构:
现在我想在Azure上运行所有这些东西,我没有找到任何相关的教程,我将应用程序部署为常规的Web应用程序,但我仍然不知道:
答案 0 :(得分:2)
1.在哪里上传脚本使用的文件?
我建议您在azure应用项目中创建一个新文件夹,例如D:\home\site\wwwroot\ProcessFile
。
但是,azure web app文件系统存储受限于您的应用服务。 (您可以在门户网站上查看它)因此,如果您的文件太大,则需要将它们存储到Azure存储中。
2.要写什么路径而不是MY-PATH?
请遵循以上绝对路径D:\home\site\wwwroot\ProcessFile\NLP.py
3.如何在Azure上运行python脚本,我应该使用什么资源以及如何使用?
据我所知,Azure Web App有自己的Python环境,但您无权更改它。由于您正在使用涉及依赖包的NLP
,因此我建议您安装Python Extension
。
关于步骤的详细信息,请遵循我之前回答的案例。
1。install odbc driver to azure app service
安装软件包后,需要更改代码中的路径参数。
String python= "D:\home\python362x86\python.exe";
String pythonScriptPath = "D:\home\site\wwwroot\ProcessFile\NLP.py";
String[] cmd = new String[3];
cmd[0] = "python"; // check version of installed python: python -V
cmd[1] = pythonScriptPath;
cmd[2]="playing sport";
// create runtime to execute external command
Runtime rt = Runtime.getRuntime();
Process pr = rt.exec(cmd);
希望它对你有所帮助。如有任何疑虑,请随时告诉我。