简体   繁体   中英

How can I install a package using easy_install from a package on the local host?

I am trying to install Python packages using easy_install from a local directory.

The reason I am doing this is because of network/IT issues.

I have a workstation (Ubuntu) that can access easy_install's repositories on the Internet. I can install things without any problems.

We have a lab network that is closed off to the Internet. I have an Ubuntu VM on this lab network. I cannot use easy_install (or pip) to install anything because it is blocked off from the repositories. I need to install some Python packages so I need to work around this limitation.

The way I got around this limitation for pip was to do a "pip download" of a package, then SCP the package file to the VM in the lab network and do a "pip install" of the package file.

I am trying to do this with easy_install. I was able to download the easy_install package by issuing this command

    > easy_install -q --editable --build-directory . <package name>

For example, suppose I wanted to install pip using easy_install. I have the pip directory after downloading the source code thru easy_install. I can tar the pip directory and SCP it over to the VM. Is there a way to tell easy_install on the VM to install using the files from the pip directory rather than try to install via the external repository?

I have searched for a similar question to this using the easy_install tag but I don't see anything so I thought I'd ask.

devpi-server is a caching PyPI proxy. If you use it to install packages on one host, it will forward requests to https://pypi.python.org/pypi , and save everything it downloads. Then you copy over a tarball of ~/.devpi to another host, launch the server, and have devpi-server serve up the cached files.

Host 1 (online):

$ easy_install --user devpi-server
$ devpi-server --start
$ easy_install --user -i http://localhost:3141/root/pypi/ Django

Copy ~/.devpi from Host 1 to Host 2

Somehow you'll also need to copy devpi-server over to the offline box too. It has quite a few dependencies. Maybe to bootstrap you could create a basic VM, run easy_install --user devpi-server , then tar up ~/.local and copy it over?

Host 2 (no internet):

$ devpi-server --start
$ easy_install --user -i http://localhost:3141/root/pypi/ Django
# Success!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM