简体   繁体   中英

Azure failing to run python script

I built a simple web app using Flask. What this does is basically take data from a form and sends a POST - which is then passed as a command line argument to the script using

os.popen("python3 script.py " + postArgument).read()

The command is stored in a variable which is then passed to an element in a new page with the results.

About the script: It runs the string in the POST through an API, gets some data, processes it, sends it to another API and finally prints the results (which are finally stored in the variable)

It works fine on a local server. But Azure fails to return anything. The string is empty.

How do I get some terminal logs?

Is there a solution?

Per my experience, it seems that the issue was caused by the Python 3 (even for Python 2) interpreter called python on Azure, not python3 .

So if you had configured the Python 3 runtime environment for the Application settings on Azure portal as the figure below, please using python script.py instead of python3 script.py in your code.

在此处输入图片说明

Or you also can use the absolute path of Python 3 on Azure WebApp D:\\Python34\\python instead of python3 in your code, as below.

在此处输入图片说明

However, I also doubt the another possible issue for you besides the above case. You may use some python packages which be not install using pip on Azure. If so, you need to refer to the section Troubleshooting - Package Installation of the Azure offical document for Python to resolve the possible issue.

Hope it helps. Any concern & update, please feel free to let me know.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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