0

I have to prepare installation of a python3 FastAPI based service to a server without an internet conenction.

I installed all needed stuff in a minimal Debian container, tested the service and called

pip freeze > requirements.txt

I got:

asgiref==3.4.1
certifi==2020.6.20
chardet==4.0.0
click==8.0.1
fastapi==0.68.0
fastapi-utils==0.2.1
greenlet==1.1.1
h11==0.12.0
httptools==0.2.0
idna==2.10
iso8601==0.1.16
m3u8==0.9.0
pydantic==1.8.2
python-dotenv==0.19.0
PyYAML==5.4.1
requests==2.25.1
six==1.16.0
SQLAlchemy==1.4.23
starlette==0.14.2
typing-extensions==3.10.0.0
urllib3==1.26.5
uvicorn==0.15.0
uvloop==0.16.0
watchgod==0.7
websockets==9.1

Then I called on my host

mkdir dependencies
pip download -r requirements.txt -d "./dependencies"
cp requirements.txt ./dependencies/
tar cvfz dependencies.tar.gz dependencies

The approach is based on these SO questions and answers:

installing python packages without internet and using source code as .tar.gz and .whl
How to install packages offline?

I created a new fresh Debian container with access to archive made above, installed python3 and python3-pip, disconnected my host from internet and tried this:

root@3eed3ed8cafc:~/temp# pip3 install --no-index --find-links="./dependencies/" -r dependencies/requirements.txt
Looking in links: ./dependencies/
Processing ./dependencies/asgiref-3.4.1-py3-none-any.whl
Processing ./dependencies/certifi-2020.6.20-py2.py3-none-any.whl
Processing ./dependencies/chardet-4.0.0-py2.py3-none-any.whl
Processing ./dependencies/click-8.0.1-py3-none-any.whl
Processing ./dependencies/fastapi-0.68.0-py3-none-any.whl
Processing ./dependencies/fastapi_utils-0.2.1-py3-none-any.whl
ERROR: Could not find a version that satisfies the requirement greenlet==1.1.1
ERROR: No matching distribution found for greenlet==1.1.1

But it is there as greenlet-1.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl wheel:

root@3eed3ed8cafc:~/temp# ls dependencies
PyYAML-5.4.1-cp38-cp38-manylinux1_x86_64.whl                                       m3u8-0.9.0-py3-none-any.whl
SQLAlchemy-1.4.23-cp38-cp38-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl  pydantic-1.8.2-cp38-cp38-manylinux2014_x86_64.whl
asgiref-3.4.1-py3-none-any.whl                                             python_dotenv-0.19.0-py2.py3-none-any.whl
certifi-2020.6.20-py2.py3-none-any.whl                                         requests-2.25.1-py2.py3-none-any.whl
chardet-4.0.0-py2.py3-none-any.whl                                         requirements.txt
click-8.0.1-py3-none-any.whl                                               six-1.16.0-py2.py3-none-any.whl
fastapi-0.68.0-py3-none-any.whl                                            starlette-0.14.2-py3-none-any.whl
fastapi_utils-0.2.1-py3-none-any.whl                                           typing_extensions-3.10.0.0-py3-none-any.whl
greenlet-1.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl                        urllib3-1.26.5-py2.py3-none-any.whl
h11-0.12.0-py3-none-any.whl                                            uvicorn-0.15.0-py3-none-any.whl
httptools-0.2.0-cp38-cp38-manylinux1_x86_64.whl                                    uvloop-0.16.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl
idna-2.10-py2.py3-none-any.whl                                             watchgod-0.7-py3-none-any.whl
iso8601-0.1.16-py2.py3-none-any.whl                                        websockets-9.1-cp38-cp38-manylinux2010_x86_64.whl

Not even moving the greenlet to the first line in requirements.txt helped.

What is wrong?

Roman Pavelka
  • 3,736
  • 2
  • 11
  • 28
  • `greenlet-1.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl` is a wheel for Python 3.8 for Linux running on 64-bit Intel/AMD processor. Is your offline environment the same? Downloading must be performed on the same (the same architecture, platform, processor, OS, Python version) connected host (or a container or a virtual machine) as the offline host. Is your `pip` fresh enough? – phd Aug 19 '21 at 17:24
  • @phd thank you for this point. Well, both has been done in the same Debian container, with `apt update && apt install python3 python3-pip` However this makes me think how good idea is this to do for universal offline installation... :-/ – Roman Pavelka Aug 19 '21 at 17:41
  • Well, it's the only way for offline installation. – phd Aug 19 '21 at 17:46

0 Answers0