0

I'm an experienced programmer, but very new to python. My company requires us to do development on a private network for some of our projects. There is a pypi index on the private network which can be used to install packages using pip. Recently, while needing to install a package, the pypi index when down and was down for several hours. Although it did come back up eventually, the situation begs the question, how do I install packages (maybe manually without pip) in the absense of an index? I've tried to google this, but came up empty. I'm sure there's a way, but I'm probably not searching for the right phrase. Thanks for any help with.

Sanjeev
  • 1,517
  • 1
  • 18
  • 30
  • I'm not sure if I got your problem correctly, but wheel packages can help. https://www.lfd.uci.edu/~gohlke/pythonlibs/ – Parth Sarthi Sharma Jun 26 '19 at 15:28
  • @בנימיןכהן I don't think that is necessarily they're asking about. I think @Sanjeev is asking about how to still `pip install` a package when an index goes down – Edward Minnix Jun 26 '19 at 15:29
  • At the very least, I think answers relating to that would be worth mentioning, which the other post you linked to does not – Edward Minnix Jun 26 '19 at 15:30
  • https://stackoverflow.com/search?q=%5Bpip%5D+offline+installation – phd Jun 26 '19 at 15:48

3 Answers3

1

You can manually install Python packages if you have read access to the package repositories. Every Python package has a setup.py file in the root directory and you can do something like

python setup.py sdist

This creates a subdirectory called dist which contains a compressed archived file, tar.gz or .zip depending in your OS. You can pass this archived file to pip and install the package

pip3 install some-python-package.tar.gz
prithajnath
  • 2,000
  • 14
  • 17
1

I would download the wheel and install that. For this to you do need to install the wheel package:

pip install wheel

You can then tell pip to install the project (and it'll download the wheel if available), or the wheel file directly:

pip install project_name  # download and install
pip install wheel_file.whl  # directly install the wheel

The wheel module is also runnable from the command line and you can use it to install already-downloaded wheels:

python -m wheel install wheel_file.whl
Kurtis Streutker
  • 1,157
  • 10
  • 13
0

There are a few ways you can get around this issue. The two that I know of are:

  1. Use a proxy to get to the standard PyPI. If your company permits it, then you can tunnel your traffic through their proxy and install packages from PyPA's standard locations.

  2. Use a locally hosted index. All you need is a directory structured like https://pypi.org/simple/, and you can then pip install -i ~/my/personal/index/path and packages will be installed from there.

Edward Minnix
  • 2,889
  • 1
  • 13
  • 26