简体   繁体   English

使用 VS Code 进行 Azure 功能本地开发时出现 SSLError

[英]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所在的位置,例如

  • libcrypto-1_1-x64.dll libcrypto-1_1-x64.dll
  • libssl-1_1-x64.dll libssl-1_1-x64.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.

相关问题 使用 VS Code 在本地调试 Azure 函数时无法进行身份验证 - Cannot authenticate when debugging Azure Functions in local with VS Code VS 代码中的 Azure 函数 - Azure Functions in VS Code 在 VS Code 和 virtualenv 中使用 Azure 函数时找不到 Numpy 模块 - Numpy module not found when working with Azure Functions in VS Code and virtualenv 使用 conda 环境在 VS 代码中部署 Azure Functions - Azure Functions deployment in VS code using conda environment VS 代码 SSLError 和项目的路径附加 - VS code SSLError and path appending for a project 执行表存储实体查询时,带有python的Azure ML-(SSLError(SSLError(&#39;写操作超时&#39;,),)) - Azure ML with python - (SSLError(SSLError('The write operation timed out',),),) when doing a table storage entity query 使用Google API客户端库时出现SSLError - SSLError when using google api client library 使用 urllib3 时 ssl.SSLError - ssl.SSLError when using urllib3 如何在 VS Code 环境中修复“发生异常:SSLError HTTPSConnectionPool” - how to fix "Exception has occurred: SSLError HTTPSConnectionPool" in VS Code environment Python 在 VS Code 中运行时跳过函数 - Python skipping functions when ran in VS Code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM