Hi!

There is something wrong with my current development environment. I have an Azure Function with these dependencies:

azure-functions
requests
Pillow
numpy
flask
tensorflow
opencv-python

And I got this error when I press F5 / Run the project in local mode.

> 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.
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 (from versions: none)
ERROR: No matching distribution found for azure-functions
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 "C:\Program Files\PowerShell\7\pwsh.exe -Command .venv\Scripts\python -m pip install -r requirements.txt" terminated with exit code: 1.

Terminal will be reused by tasks, press any key to close it.

By default, Azure Functions works with a Python virtual environment. This helps to isolate our current dev environment, and also to match the same features and requisites that the function will use on Azure.

That’s why the 1st command, defined in the tasks.json file, starts installing the requirements using pip from the requirements.txt file.

At this moment I got the TSL/SSL error. I searched and read a lot, and at the end, I find 2 options:

  • Reinstall my dev environment from zero.
  • Run the pip install packages commands adding the –trusted-host argument.

I started for the 2nd option running this commands in the Terminal in Visual Studio Code.

.venv\Scripts\python -m pip install --trusted-host pypi.org azure-functions
.venv\Scripts\python -m pip install --trusted-host pypi.org requests
.venv\Scripts\python -m pip install --trusted-host pypi.org Pillow
.venv\Scripts\python -m pip install --trusted-host pypi.org numpy
.venv\Scripts\python -m pip install --trusted-host pypi.org flask
.venv\Scripts\python -m pip install --trusted-host pypi.org tensorflow
.venv\Scripts\python -m pip install --trusted-host pypi.org opencv-python

This action does not solve my TLS/SSL problem.

However, it allows me to continue debug and run my functions locally. When I run my function, I got a output similar to this one:

requirements satisfied on function local run

I’ll share the solution when I solve the SSL/TLS problem!

Happy coding!

Greetings

El Bruno

More posts in my blog ElBruno.com.

More info in https://beacons.ai/elbruno


References


¿Con ganas de ponerte al día?

En Lemoncode te ofrecemos formación online impartida por profesionales que se baten el cobre en consultoría:

One response to “#AzureFunctions ⚡- Pip and TLS/SSL error on Debugging with #Python 🐍”

  1. […] #AzureFunctions ⚡- Pip and TLS/SSL error on Debugging with #Python (Bruno Capuano) […]

    Like

Leave a comment

Discover more from El Bruno

Subscribe now to keep reading and get access to the full archive.

Continue reading