I want to install some packages on the server which does not access to internet. so I have to take packages and send them to the server. But I do not know how can I install them.
-
Possible duplicate of [Python Packages Offline Installation](https://stackoverflow.com/questions/11091623/python-packages-offline-installation) – phd Jan 16 '19 at 17:25
-
https://stackoverflow.com/search?q=%5Bpip%5D+offline+installation – phd Jan 16 '19 at 17:25
4 Answers
Download all the packages you need and send them to the server where you need to install them. It doesn't matter if they have *whl
or *tar.gz
extension. Then install them one by one using pip
:
pip install path/to/package
or:
python -m pip install path/to/package
The second option is useful if you have multiple interpreters on the server (e.g. python2 and python3 or multiple versions of either of them). In such case replace python
with the one you want to use, e.g:
python3 -m pip install path/to/package
If you have a lot of packages, you can list them in a requirement file as you would normally do when you have access to the internet. Then instead of putting the names of the packages into the file, put the paths to the packages (one path per line). When you have the file, install all packages by typing:
python -m pip install -r requirements.txt
In the requirements file you can also mix between different types of the packages (*whl
and *tar.gz
). The only thing to take care about is to download the correct versions of the packages you need for the platform you have (64bit packages for 64bit platform etc.).
You can find more information regarding pip install
in its documentation.

- 2,304
- 2
- 17
- 21
-
1This doesn't work unless both servers are the same OS and architecture. – deed02392 Apr 25 '19 at 22:24
-
@deed02392 I'm not sure what 2 servers you are talking about. What exactly is not working for you? – machnic May 02 '19 at 15:51
-
-
Sure, I understood that you use 2 different operating systems but why is it a problem? If your server with CentOS doesn't have access to the internet then download the packages for CentOS from [pypi](https://pypi.org/), put them to some place where the server have access and use [requirement specifiers](https://pip.pypa.io/en/stable/reference/pip_install/#requirement-specifiers) in your `requirements.txt` (using `sys_platform` probably will be enough. If not then use combination of multiple specifiers). – machnic May 03 '19 at 08:26
-
2I know I can download them from the pypi website, I'm just letting others know if they try to use pip as shown in this answer, it won't work for them across OSs if for example they need a package which has platform specific dependencies. – deed02392 May 03 '19 at 08:34
-
All the snippets above suggest to use paths to the downloaded packages which of course should match the platform on which you want to use them. If the package has dependencies then you need do download correct dependencies as well (assuming that the server is offline). Writing a proper requirements file which handles multiple OS's wasn't really in the scope of the question and I mentioned above that you need to take care about the architecture. Please be more specific about the part of the answer which doesn't work or is misleading to you because I don't see it – machnic May 03 '19 at 09:34
You can either download the packages from the website and run python setup.py install
. Or you can run a pip install
on a local dir, such as :
pip install path/to/tar/ball

- 5,751
- 3
- 17
- 42
Download the wheel
packages from https://www.lfd.uci.edu/~gohlke/pythonlibs/ . You may install the .whl
packages by pip install (package.whl)
, refer installing wheels using pip for more.

- 512
- 5
- 16
-
It doesn't matter from where the package is downloaded. `pip install path/to/package` is enough for `*whl` and `*tar.gz` files – machnic Jan 16 '19 at 09:11
-
1
Download the package from website and extract the tar ball.
run python setup.py install

- 836
- 4
- 17