Deploy Flask Application to Azure App Service

Hi Experts,
I’m new to Python. I’m trying to deploy Python Flask application to Azure App Service through VS Code. I had created App Service. I had generated requirements.txt file through virtual environment. While trying to deploy, I’m getting the error as could not install packages due to an OS Error: HTTPSConnectionPool. I had shared the screenshot for your reference.

Could You copy&paste the error text here? It would be easier for the rest of us to find out what’s going on

I had shared both warning and error below:
WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:1000)’))’: /packages/45/86/4736ac618d82a20d87d2f92ae19441ebc7ac9e7a581d7e58bbe79233b24a/asttokens-2.4.1-py2.py3-none-any.whl.metadata
WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:1000)’))’: /packages/45/86/4736ac618d82a20d87d2f92ae19441ebc7ac9e7a581d7e58bbe79233b24a/asttokens-2.4.1-py2.py3-none-any.whl.metadata
WARNING: Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:1000)’))’: /packages/45/86/4736ac618d82a20d87d2f92ae19441ebc7ac9e7a581d7e58bbe79233b24a/asttokens-2.4.1-py2.py3-none-any.whl.metadata
WARNING: Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:1000)’))’: /packages/45/86/4736ac618d82a20d87d2f92ae19441ebc7ac9e7a581d7e58bbe79233b24a/asttokens-2.4.1-py2.py3-none-any.whl.metadata
WARNING: Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by ‘SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:1000)’))’: /packages/45/86/4736ac618d82a20d87d2f92ae19441ebc7ac9e7a581d7e58bbe79233b24a/asttokens-2.4.1-py2.py3-none-any.whl.metadata
ERROR: Could not install packages due to an OSError: HTTPSConnectionPool(host=‘files.pythonhosted.org’, port=443): Max retries exceeded with url: /packages/45/86/4736ac618d82a20d87d2f92ae19441ebc7ac9e7a581d7e58bbe79233b24a/asttokens-2.4.1-py2.py3-none-any.whl.metadata (Caused by SSLError(SSLEOFError(8, ‘EOF occurred in violation of protocol (_ssl.c:1000)’)))
“2024-05-24 11:04:36”|ERROR|[11:04:27+0000] Collecting asttokens==2.4.1 (from -r requirements.txt (line 1)) | Exit code: 1 | Please review your requirements.txt | More information: Configure Linux Python apps - Azure App Service | Microsoft Learn
I had shared my requirements.txt file:
asttokens==2.4.1
attrs==23.2.0
azure-core==1.30.1
azure-identity==1.16.0
backcall==0.2.0
beautifulsoup4==4.12.3
bleach==6.1.0
blinker==1.7.0
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
colorama==0.4.6
cryptography==42.0.7
decorator==5.1.1
defusedxml==0.7.1
docopt==0.6.2
et-xmlfile==1.1.0
executing==2.0.1
fastjsonschema==2.19.1
Flask==3.0.3
gunicorn==22.0.0
idna==3.7
ipython==8.12.3
itsdangerous==2.2.0
jedi==0.19.1
Jinja2==3.1.3
jsonschema==4.22.0
jsonschema-specifications==2023.12.1
jupyter_client==8.6.1
jupyter_core==5.7.2
jupyterlab_pygments==0.3.0
lxml==5.2.1
MarkupSafe==2.1.5
matplotlib-inline==0.1.7
mistune==3.0.2
msal==1.28.0
msal-extensions==1.1.0
nbclient==0.10.0
nbconvert==7.16.4
nbformat==5.10.4
numpy==1.26.4
openpyxl==3.1.2
packaging==24.0
pandas==2.2.1
pandocfilters==1.5.1
parso==0.8.4
pickleshare==0.7.5
pipreqs==0.5.0
platformdirs==4.2.1
portalocker==2.8.2
prompt-toolkit==3.0.43
pure-eval==0.2.2
pycparser==2.22
Pygments==2.17.2
PyJWT==2.8.0
pyodbc==5.1.0
python-dateutil==2.9.0.post0
pytz==2024.1
pywin32==306
pyzmq==26.0.3
referencing==0.35.1
requests==2.31.0
rpds-py==0.18.0
six==1.16.0
soupsieve==2.5
stack-data==0.6.3
tinycss2==1.3.0
tornado==6.4
traitlets==5.14.3
typing_extensions==4.11.0
tzdata==2024.1
urllib3==2.2.1
wcwidth==0.2.13
webencodings==0.5.1
Werkzeug==3.0.2
yarg==0.1.9

Hi @FelixLeg ,
I 'm trying to reply to your question, but its not posting, it shows Akismet has temporarily hidden your post.

Maybe as a new user here, you have to wait for admins? I don’t know, I even don’t know what “Akismet” is :confused:

@admins could you check this?

Hi @FelixLeg,
I had sent the answer for your question. Please review it and let me know the solution.

Hmm, I’m not sure, but try to remove (just temporary) the first line from requirements.txt file and check if it spits out a similar error

I had removed the first line in the requirements.txt file, it showed the same error for second line(attrs==23.2.0).

So it is a SSL error. :frowning:
Do you have the same error when installing anything via pip locally (on your computer)?

If not, then maybe try pip download ... and move the *.whl files onto the server and try pip install *.whl on it? Frankly, this touches the very border of my knowledge, so I hope this works :crossed_fingers:

I don’t face any issues while using pip in my computer locally.
can you please explain briefly from pip download?

Well, you just run the same way as you run pip install: just replace install with download, and do it on your local machine :slight_smile:

If someone is a new user here, the Akismat system controls spam and their initial post needs to be approved by an admin. It should be approved in 24 hours. It happened to me too.

Also.

  1. In April 2024 Azure Function Apps only supported Python 3.11. I don’t know about other Azure services. Did you check to see what versions of Python it supports now? Is your version of Python supported? Unfortunately I can’t remember how I found the list of supported Python versions on Azure.
  2. Does Azure support all the packages you are trying to install?

I’m going to have to deal with this same thing, making web apps on Azure but I do not have the right access to Azure yet.

Don’t forget to use the Azure libraries with Python as well, to use Azure objects. Use the Azure libraries (SDK) for Python - Python on Azure | Microsoft Learn

This might help: The Azure Functions library for Python supports python 3.7-3.11. azure-functions · PyPI

Thanks for the response. I’m currently using python 3.12 version I think so Az App service is not supporting. I will try to install other versions and also check about the Azure packages.