尝试从VS Code运行python azure函数。使用requirements.txt导入必要的库。尝试安装Shapely == 1.6.4.post2时,出现错误消息,请参见下面的提示。
我已经尝试过的方法:在不使用ran的情况下在本地运行python函数 天蓝色函数 并使用了清晰的python环境-效果良好。
import datetime
import logging
from shapely.geometry import shape, Point, Polygon
import azure.functions as func
def main(mytimer: func.TimerRequest) -> None:
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
if mytimer.past_due:
logging.info('The timer is past due!')
logging.info('Python timer trigger function ran at %s', utc_timestamp)
Content of requirements.txt:
pip==19.1.1
Shapely==1.6.4.post2
> Executing task in folder PythonAzureFunctions: .env\Scripts\python -m pip install -r requirements.txt <
Requirement already satisfied: pip==19.1.1 in e:\onedrive-abb\onedrive - abb\work\pythonazurefunctions\.env\lib\site-packages (from -r requirements.txt (line 1)) (19.1.1)
Collecting Shapely==1.6.4.post2 (from -r requirements.txt (line 2))
Using cached https://files.pythonhosted.org/packages/a2/fb/7a7af9ef7a35d16fa23b127abee272cfc483ca89029b73e92e93cdf36e6b/Shapely-1.6.4.post2.tar.gz
ERROR: Complete output from command python setup.py egg_info:
ERROR: Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Users\T\AppData\Local\Temp\pip-install-_xq0ijpu\Shapely\setup.py", line 80, in <module>
from shapely._buildcfg import geos_version_string, geos_version, \
File "C:\Users\T\AppData\Local\Temp\pip-install-_xq0ijpu\Shapely\shapely\_buildcfg.py", line 200, in <module>
lgeos = CDLL("geos_c.dll")
File "C:\Program Files (x86)\Microsoft Visual Studio\Shared\Python36_64\lib\ctypes\__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] The specified module could not be found
----------------------------------------
ERROR: Command "python setup.py egg_info" failed with error code 1 in C:\Users\T\AppData\Local\Temp\pip-install-_xq0ijpu\Shapely\
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
答案 0 :(得分:0)
Shapely需要单独安装到python环境中。
手动从以下位置下载文件:https://www.lfd.uci.edu/~gohlke/pythonlibs/#shapely
然后使用: pip install Shapely 1.6.4.post1 cp35 cp35m win_amd64.whl
https://gis.stackexchange.com/questions/62925/why-is-shapely-not-installing-correctly