How to install packages offline?

后端 未结 10 890
一个人的身影
一个人的身影 2020-11-22 00:38

What\'s the best way to download a python package and it\'s dependencies from pypi for offline installation on another machine? Is there any easy way to do this with pip or

10条回答
  •  心在旅途
    2020-11-22 01:09

    Using wheel compiled packages.

    bundle up:

    $ tempdir=$(mktemp -d /tmp/wheelhouse-XXXXX)
    $ pip wheel -r requirements.txt --wheel-dir=$tempdir
    $ cwd=`pwd`
    $ (cd "$tempdir"; tar -cjvf "$cwd/bundled.tar.bz2" *)
    

    copy tarball and install:

    $ tempdir=$(mktemp -d /tmp/wheelhouse-XXXXX)
    $ (cd $tempdir; tar -xvf /path/to/bundled.tar.bz2)
    $ pip install --force-reinstall --ignore-installed --upgrade --no-index --no-deps $tempdir/*
    

    Note wheel binary packages are not across machines.

    More ref. here: https://pip.pypa.io/en/stable/user_guide/#installation-bundles

提交回复
热议问题