簡體   English   中英

在Azure函數v2中使用Shapely lib-python

[英]Using shapely lib in azure functions v2 - python

試圖從VS Code運行python azure函數。 使用requirements.txt導入必要的庫。 嘗試安裝Shapely == 1.6.4.post2時,出現錯誤消息,請參見下面的內容。

我已經嘗試過的方法:在不使用azure函數的情況下在本地運行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.

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM