I have a server (RHEL) that I need to install specific python packages on. However, my server is firewalled off from internet access so I am not able to install any packages using pip. Is there a way to "manually" download packages to my local workstation and then push them and install them to my isolated RHEL system. Is this possible? Is it possible to manually push python packages and install them onto a system without internet access?
3 Answers
from a pc that connected to internet :
pip download yourpackage
copy "yourpackage.tar.gz" to server in server :
pip install "path/yourpackage.tar.gz"
if package have ".whl" file :
pip install "path/yourpackage-version.whl"
-
1I think "pip download" only works in Python 3. For those who happen to still be in Python 2, "pip install --download . yourpackage" may be the equivalent. Sep 3, 2019 at 17:03
-
Solved it...all that really needs to be done is to tar up the "site-packages" directory from a server that has the packages installed and then restore that on the desired target server.
Yes. You can download a package from PyPI, untar it and run setup.py
:
python setup.py
-
Shouldn't that be:
tar -zxvf packagename.tar.gz ; cd packagename; python setup.py
- you may well need to take care of dependencies first though.– HannuJul 22, 2015 at 19:16 -
Does this handle all of the dependent packages as well? So if I had pip installed a package, can I package up my software along with the package that I installed using pip so it can be deployed to other servers?– GregHJul 22, 2015 at 20:27
-
setup.py
is a regular Python file, it will do whatever you put in it. It's just a convention to put package installation routine in a file calledsetup.py
, you could as well use arpm
-s,deb
-s or atar
file with installation procedure described in a README file - it doesn't matter as long as all files are placed where they should be. You definitely can include all dependencies, but it's not the smartest thing to do - they will become outdated quickly. Jul 22, 2015 at 21:36 -
Solved it...all that really needs to be done is to tar up the "site-packages" directory from a server that has the packages installed and then restore that on the desired target server.– GregHJul 24, 2015 at 5:23