[英]SSLError when using VS Code for Azure Functions local development
My goal is to develop Azure Functions locally with VS Code and Python.我的目标是使用 VS Code 和 Python 在本地开发 Azure 函数。 I have an Azure Functions template with Time Trigger:
我有一个带有时间触发器的 Azure 函数模板:
import datetime
import logging
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)
I try to run that locally (conda environment) in VS Code with debugging and I will get the following:我尝试在 VS Code 中通过调试在本地(conda 环境)运行它,我将得到以下信息:
> Executing task: .venv\Scripts\python -m pip install -r requirements.txt <
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Collecting azure-functions==1.2.1 (from -r requirements.txt (line 1))
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/azure-functions/
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/azure-functions/
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/azure-functions/
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/azure-functions/
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'SSLError("Can't connect to HTTPS URL because the SSL module is not available.")': /simple/azure-functions/
Could not fetch URL https://pypi.org/simple/azure-functions/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/azure-functions/ (Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
ERROR: Could not find a version that satisfies the requirement azure-functions==1.2.1 (from -r requirements.txt (line 1)) (from versions: none)
ERROR: No matching distribution found for azure-functions==1.2.1 (from -r requirements.txt (line 1))
WARNING: pip is configured with locations that require TLS/SSL, however the ssl module in Python is not available.
Could not fetch URL https://pypi.org/simple/pip/: There was a problem confirming the ssl certificate: HTTPSConnectionPool(host='pypi.org', port=443): Max retries exceeded with url: /simple/pip/
(Caused by SSLError("Can't connect to HTTPS URL because the SSL module is not available.")) - skipping
The terminal process terminated with exit code: 1
I have added the PATH variables mentioned here我添加了此处提到的 PATH 变量
I have also found a way to install packages using --trusted-host
( link here ), but I don't know, how to use that in Azure Functions, because it utilizes requirements.txt.我还找到了一种使用
--trusted-host
(此处链接)安装软件包的方法,但我不知道如何在 Azure 函数中使用它,因为它使用了 requirements.txt。 I assume, that you can't use --trusted-host
in the requirements.txt.我假设您不能在 requirements.txt 中使用
--trusted-host
。
Check that you have C:\ProgramData\Anaconda3\Library\bin in your PATH System Environment Variable.检查您的 PATH 系统环境变量中是否有C:\ProgramData\Anaconda3\Library\bin 。
Thats where the DLLs are located eg那就是DLL所在的位置,例如
Reload your code editor.重新加载您的代码编辑器。 Test the fix by running venv\Scripts\python.exe
通过运行 venv\Scripts\python.exe 测试修复
import ssl
If the modules loads without a DLL error, it should work.如果模块加载时没有出现 DLL 错误,它应该可以工作。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.