Distributing Python virtual environments

Chris Angelico rosuav at gmail.com
Thu Mar 29 10:22:24 EDT 2018


On Fri, Mar 30, 2018 at 1:06 AM, Malcolm Greene <python at bdurham.com> wrote:
> We're using virtual environments with Python 3.6. Since all our pip
> installed modules are in our environment's local site-packages folder,
> is the distribution of a virtual environment as simple as recursively
> zipping the environment's root folder and distributing that archive to
> another machine running the same OS and same version of Python? The
> reason we would go this route vs downloading dependencies from a
> requirements.txt file is that the target machines may be in a private
> subnet with minimal access to the internet.

You'd have to also ensure that you have the same word size (32-bit,
64-bit, etc) and other criteria, and you'd have to ensure that the
same Python is available in the same location (since the venv's binary
is a symlink), but otherwise, I think you might be correct. As long as
you have the EXACT same setup, it will probably work. (Probably.) But
as an alternative, you may wish to consider replicating your PIP cache
(perhaps wiping it out first, to minimize its size); that should give
you the same ultimate effect of not requiring internet access, while
failing more gracefully if something goes wrong.

ChrisA



More information about the Python-list mailing list