我的azure函数使用python模块pywavelets,它需要依赖于numpy。这是我的requirements.txt
azure-functions
cloudpickle==0.5.3
cycler==0.10.0
dask==0.18.2
decorator==4.3.0
kiwisolver==1.0.1
matplotlib==2.2.3
networkx==2.1
numpy==1.15.0
Pillow==5.2.0
pyparsing==2.2.0
python-dateutil==2.7.3
pytz==2018.5
PyWavelets==0.5.2
scikit-image==0.14.0
scipy==1.1.0
six==1.11.0
termcolor==1.1.0
toolz==0.9.0
wget==3.2
nltk
pdfminer
sumy但是,当在本地测试函数时,我遇到了来自ModuleNotFound的pywavelets错误:
Requirement already satisfied: azure-functions in ./.venv/lib/python3.8/site-packages (from -r requirements.txt (line 5)) (1.6.0)
Collecting cloudpickle==0.5.3 (from -r requirements.txt (line 7))
Using cached https://files.pythonhosted.org/packages/e7/bf/60ae7ec1e8c6742d2abbb6819c39a48ee796793bcdb7e1d5e41a3e379ddd/cloudpickle-0.5.3-py2.py3-none-any.whl
Collecting cycler==0.10.0 (from -r requirements.txt (line 8))
Using cached https://files.pythonhosted.org/packages/f7/d2/e07d3ebb2bd7af696440ce7e754c59dd546ffe1bbe732c8ab68b9c834e61/cycler-0.10.0-py2.py3-none-any.whl
Collecting dask==0.18.2 (from -r requirements.txt (line 9))
Using cached https://files.pythonhosted.org/packages/91/52/427541141707ac533a6dcafa3bff7ff8b57ded3c9ea84d6ec014d15fbbff/dask-0.18.2-py2.py3-none-any.whl
Collecting decorator==4.3.0 (from -r requirements.txt (line 10))
Using cached https://files.pythonhosted.org/packages/bc/bb/a24838832ba35baf52f32ab1a49b906b5f82fb7c76b2f6a7e35e140bac30/decorator-4.3.0-py2.py3-none-any.whl
Collecting kiwisolver==1.0.1 (from -r requirements.txt (line 11))
Using cached https://files.pythonhosted.org/packages/31/60/494fcce70d60a598c32ee00e71542e52e27c978e5f8219fae0d4ac6e2864/kiwisolver-1.0.1.tar.gz
Collecting matplotlib==2.2.3 (from -r requirements.txt (line 12))
Using cached https://files.pythonhosted.org/packages/eb/a0/31b6ba00bc4dcbc06f0b80d1ad6119a9cc3081ecb04a00117f6c1ca3a084/matplotlib-2.2.3.tar.gz
Collecting networkx==2.1 (from -r requirements.txt (line 13))
Using cached https://files.pythonhosted.org/packages/11/42/f951cc6838a4dff6ce57211c4d7f8444809ccbe2134179950301e5c4c83c/networkx-2.1.zip
Collecting numpy==1.15.0 (from -r requirements.txt (line 14))
Using cached https://files.pythonhosted.org/packages/3a/20/c81632328b1a4e1db65f45c0a1350a9c5341fd4bbb8ea66cdd98da56fe2e/numpy-1.15.0.zip
Collecting Pillow==5.2.0 (from -r requirements.txt (line 15))
Using cached https://files.pythonhosted.org/packages/d3/c4/b45b9c0d549f482dd072055e2d3ced88f3b977f7b87c7a990228b20e7da1/Pillow-5.2.0.tar.gz
Collecting pyparsing==2.2.0 (from -r requirements.txt (line 16))
Using cached https://files.pythonhosted.org/packages/6a/8a/718fd7d3458f9fab8e67186b00abdd345b639976bc7fb3ae722e1b026a50/pyparsing-2.2.0-py2.py3-none-any.whl
Collecting python-dateutil==2.7.3 (from -r requirements.txt (line 17))
Using cached https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl
Collecting pytz==2018.5 (from -r requirements.txt (line 18))
Using cached https://files.pythonhosted.org/packages/30/4e/27c34b62430286c6d59177a0842ed90dc789ce5d1ed740887653b898779a/pytz-2018.5-py2.py3-none-any.whl
Collecting PyWavelets==0.5.2 (from -r requirements.txt (line 19))
Using cached https://files.pythonhosted.org/packages/4b/df/3fff2a8b96ef7df6e4e8642fb7569c3717ae562dd76afe0f96525c0af784/PyWavelets-0.5.2.tar.gz
ERROR: Command errored out with exit status 1:
command: /Users/chaozy/Desktop/textSum/.venv/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/private/var/folders/7m/tzzll84901gdl2lvrjb4cxkh0000gn/T/pip-install-krw2z9vf/PyWavelets/setup.py'"'"'; __file__='"'"'/private/var/folders/7m/tzzll84901gdl2lvrjb4cxkh0000gn/T/pip-install-krw2z9vf/PyWavelets/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base pip-egg-info
cwd: /private/var/folders/7m/tzzll84901gdl2lvrjb4cxkh0000gn/T/pip-install-krw2z9vf/PyWavelets/
Complete output (5 lines):
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/private/var/folders/7m/tzzll84901gdl2lvrjb4cxkh0000gn/T/pip-install-krw2z9vf/PyWavelets/setup.py", line 12, in <module>
from numpy import get_include as get_numpy_include
ModuleNotFoundError: No module named 'numpy'
----------------------------------------
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.但是我们可以从输出中看到,numpy是在PyWavelets之前安装的。
我如何解决这个问题?事先非常感谢!
更新
下面是我的代码中唯一的python脚本__init__.py:
import logging
import azure.functions as func
def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('This function processes a request.')
# I comment out all the remaining stuff发布于 2021-02-01 03:35:47
我使用与您在requirements.txt中相同的模块在我的一侧进行测试,并使用Ctrl + F5运行函数。它显示了与您提到的相同的错误消息。
这两个模块似乎存在一些冲突(在您在requirements.txt中指定的版本中)。要解决这个问题,只需删除requirements.txt中两个模块的版本即可。下面是我的requirements.txt

如果我们不指定版本,它将自动安装最新版本。在我的函数应用程序中,它使用numpy 1.20.0和PyWavelets 1.1.1,当我使用Ctrl + F5时,该函数运行成功。
https://stackoverflow.com/questions/65964789
复制相似问题