我是Azure和Python的新手,我正在尝试在Azure中运行Python脚本作为webjob。我知道我需要在webjob中包含所有包文件,但我认为我缺少一些导致错误的依赖项。这是错误日志:
[01/28/2015 03:53:29 > 52e03f: SYS INFO] Status changed to Initializing
[01/28/2015 03:53:35 > 52e03f: SYS INFO] Run script 'get_teams_espn.py' with script host - 'PythonScriptHost'
[01/28/2015 03:53:35 > 52e03f: SYS INFO] Status changed to Running
[01/28/2015 03:53:36 > 52e03f: ERR ] Traceback (most recent call last):
[01/28/2015 03:53:36 > 52e03f: ERR ] File "get_teams_espn.py", line 45, in <module>
[01/28/2015 03:53:36 > 52e03f: ERR ] teams_dict = teams_espn(url)
[01/28/2015 03:53:36 > 52e03f: ERR ] File "get_teams_espn.py", line 23, in teams_espn
[01/28/2015 03:53:36 > 52e03f: ERR ] soup = BeautifulSoup(r.content, 'lxml')
[01/28/2015 03:53:36 > 52e03f: ERR ] File "site-packages\bs4\__init__.py", line 152, in __init__
[01/28/2015 03:53:36 > 52e03f: ERR ] % ",".join(features))
[01/28/2015 03:53:37 > 52e03f: ERR ] bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?
[01/28/2015 03:53:37 > 52e03f: SYS INFO] Status changed to Failed
[01/28/2015 03:53:37 > 52e03f: SYS ERR ] Job failed due to exit code 1
这里是我的导入:
import sys
sys.path.append("site-packages")
import csv
import lxml
import requests
from bs4 import BeautifulSoup
我需要哪些其他软件包来使这个脚本工作?或者我没有设置我的脚本来查找包文件?请帮忙,谢谢!
答案 0 :(得分:0)
我能够使用无法直接在Azure环境中构建的python包。例如,如果您想要包含依赖于lxml
绑定的包。可以通过告诉Azure环境直接从wheel文件安装而不是下载远程资源并对其进行编译来解决此问题。
创建一个文件夹&#39; wheelhouse&#39;:
mkdir wheelhouse
从Gohlke's Unofficial Windows Binaries获取合适的lxml
轮子二进制文件,并将其复制到&#39;驾驶室&#39;目录。对我来说这个版本
lxml-3.6.0-cp34-cp34m-win32.whl
完成了这项工作。
我必须将lxml-3.6.0-cp34-cp34m-win32.whl
重命名为lxml-3.6.0-py3-none-any.whl
才能正常运行。最后,请务必在第1行的requirements.txt
以下内容中加入:
--no-index
--find-links wheelhouse
lxml==3.6.0
otherWheelsFile_pre-compiled==1.x.x
第一行告诉部署中的pip不检查远程源,第二行告诉我们在哪里寻找安装包。
我还在本地为与Web应用程序相关的软件包创建了wheel文件。重要的是解决所有依赖关系并将轮文件放入wheelhouse
目录。