Photo by Sammyayot254 on Unsplash
Sometimes server must run in the local network and with a strict firewall to the internet. And the story begins when you wanna install your python apps into your server, tomorrow. Then, before you sleep, you are thinking about
“Is it possible to install my requirement.txt into the server without Internet?”
Yes, it is.
Don’t worry friends, I will explain to you the solution :D
Search your package in The Python Package Index (PyPI)
First, you must check your package in the PyPI, and for example, I will install pycryptodome 3.14.1 Once you get the page above, go to the Download files. And get the compressed package, but don’t forget to compare the hash file first if you don’t want your package to be a fake one. The picture below is what the compressed files look like:
Extract the package
Save the files into your package folder, then you will be able to manage your packages in the future.
Build and install the package
If you prefer to make a new virtual environment for your Python pip, just do it first. After that, run this command to install the package:
python3 setup.py build && python3 setup.py install
When your installation finishes, check your package with
It’s easy, right?
You have installed the Python package without an internet connection. But when you download the compressed file, literally you still need the internet connection.
This method will be useful when you are making an app in a docker image or building your local package repository. If this article is useful, don’t forget to save it into your reading list.
Thanks for reading.