简体   繁体   English

Azure - numpy - OSError:[WinError 193]%1不是有效的Win32应用程序

[英]Azure - numpy - OSError: [WinError 193] %1 is not a valid Win32 application

I am attempting to schedule Python scripts to run on a regular basis using Azure. 我正在尝试使用Azure定期运行Python脚本。 Following the steps here , I have created a WebJob inside a Web App. 按照这里的步骤,我在Web App中创建了一个WebJob。 To the WebJob I have uploaded .zip folder containing my Python script and these modules . 我已经上传了包含我的Python脚本和这些模块的 .zip文件夹到WebJob。

My code is very simple: 我的代码非常简单:

import pandas as pd

A = [1,2,3,4]
B = ['a','b','c','d']

df = pd.DataFrame({'a':A,'b':B})

print(df)

On running the WebJob, I get the following error: 在运行WebJob时,我收到以下错误:

[06/17/2019 16:48:27 > e6e459: SYS INFO] Status changed to Initializing
[06/17/2019 16:49:01 > e6e459: SYS INFO] Run script 'Test12.py' with script host - 'PythonScriptHost'
[06/17/2019 16:49:01 > e6e459: SYS INFO] Status changed to Running
[06/17/2019 16:49:01 > e6e459: ERR ] Traceback (most recent call last):
[06/17/2019 16:49:01 > e6e459: ERR ]   File "Test12.py", line 1, in <module>
[06/17/2019 16:49:01 > e6e459: ERR ]     import pandas as pd
[06/17/2019 16:49:01 > e6e459: ERR ]   File "D:\local\Temp\jobs\triggered\Test12\2bjz15ce.qpm\pandas\__init__.py", line 13, in <module>
[06/17/2019 16:49:01 > e6e459: ERR ]     __import__(dependency)
[06/17/2019 16:49:01 > e6e459: ERR ]   File "D:\local\Temp\jobs\triggered\Test12\2bjz15ce.qpm\numpy\__init__.py", line 142, in <module>
[06/17/2019 16:49:01 > e6e459: ERR ]     from . import core
[06/17/2019 16:49:01 > e6e459: ERR ]   File "D:\local\Temp\jobs\triggered\Test12\2bjz15ce.qpm\numpy\core\__init__.py", line 23, in <module>
[06/17/2019 16:49:01 > e6e459: ERR ]     WinDLL(os.path.abspath(filename))
[06/17/2019 16:49:01 > e6e459: ERR ]   File "D:\Python34\lib\ctypes\__init__.py", line 348, in __init__
[06/17/2019 16:49:01 > e6e459: ERR ]     self._handle = _dlopen(self._name, mode)
[06/17/2019 16:49:01 > e6e459: ERR ] OSError: [WinError 193] %1 is not a valid Win32 application
[06/17/2019 16:49:01 > e6e459: SYS INFO] Status changed to Failed
[06/17/2019 16:49:01 > e6e459: SYS ERR ] Job failed due to exit code 1

How can I solve this? 我怎么解决这个问题?

According to your error information, obviously the issue was caused by the Python script inside your WebJob zip file which is not an executable file for your current Azure WebApp. 根据您的错误信息,显然问题是由WebJob zip文件中的Python脚本引起的,该文件不是当前Azure WebApp的可执行文件。 So please check your configuration on Azure portal whether be set correctly for Stack settings as the figure below. 因此,请检查Azure门户上的配置是否正确Stack settings ,如下图所示。

在此输入图像描述

Otherwise, if the above operation can not fix it for your current WebApp instance, a workaround solution is to add a .bat file into your WebJob zip file as a startup file to help running your Python script, because Azure WebApp default supports .cmd , .exe , .bat using Windows cmd, please refer to the section Supported file types for scripts or programs of the offical document Run Background tasks with WebJobs in Azure App Service to know it. 否则,如果上述操作无法为当前的WebApp实例修复它,则解决方法是将.bat文件作为启动文件添加到WebJob zip文件中以帮助运行Python脚本,因为Azure WebApp默认支持.cmd ,使用Windows cmd的.exe.bat ,请参阅Run Background tasks with WebJobs in Azure App Service的官方文档的Supported file types for scripts or programs部分。

And for example to add a file named run.bat , the code using python.exe (version 3.6.6 ) in the absolute Python path D:\\Python34\\ as below. 例如,添加名为run.bat的文件,使用python.exe (版本3.6.6 )在绝对Python路径D:\\Python34\\中的代码如下所示。

D:\Python34\python.exe Test12.py

Hope it helps. 希望能帮助到你。 Any concern, please feel free to let me know. 如有任何疑虑,请随时告诉我。

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

相关问题 OSError: [WinError 193] %1 不是 Python 中的有效 Win32 应用程序 - OSError: [WinError 193] %1 is not a valid Win32 application in python OSError: [WinError 193] %1 不是有效的 Win32 应用程序 - OSError: [WinError 193] %1 is not a valid Win32 application OSError: [WinError 193] %1 不是有效的 Win32 应用程序 (Pandas) - OSError: [WinError 193] %1 is not a valid Win32 application (Pandas) OSError: [WinError 193] %1 不是有效的 Win32 应用程序 - python - OSError: [WinError 193] %1 is not a valid Win32 application - python OSError: [WinError 193] %1 不是有效的 Win32 应用程序 Python - OSError: [WinError 193] %1 is not a valid Win32 application Python OSError: [WinError 193] %1 不是 CTypes 中的有效 Win32 应用程序 - OSError: [WinError 193] %1 is not a valid Win32 application in CTypes OSError: [WinError 193] %1 不是有效的 Win32 应用程序 - nltk - OSError: [WinError 193] %1 is not a valid Win32 application - nltk OSError: [WinError 193] %1 不是有效的 Win32 应用程序 (LibTiff) - OSError: [WinError 193] %1 is not a valid Win32 application (LibTiff) 如何修复“OSError: [WinError 193] %1 不是有效的 Win32 应用程序” - How to fix"OSError: [WinError 193] %1 is not a valid Win32 application" 无法解决OSError:[WinError 193]%1不是有效的Win32应用程序 - Unable to resolve OSError: [WinError 193] %1 is not a valid Win32 application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM