Results 1 to 2 of 2

Thread: How to copy python virtual environment (duplicate virtualenv) Share/Save - My123World.Com!

  1. #1
    ... I am no Expert b0nd's Avatar
    Join Date
    Jul 2010
    Location #g4h

    How to copy python virtual environment (duplicate virtualenv)

    Requirement: User has a python virtual environment up and running; for some reason he needs to make a copy of it on same machine at different location

    Go to original virtualenv and run:
    pip freeze > modules.txt

    Go to new virtualenv, copy modules.txt into it and run:
    pip install -r modules.txt

    modules.txt file is a file that contains a list of all the python packages you want to install.

    [*] To follow the path: look to the master, follow the master, walk with the master, see through the master,
    ------> become the master!!! <------
    [*] Everyone has a will to WIN but very few have the will to prepare to WIN
    [*] Invest yourself in everything you do, there's fun in being serious

  2. #2
    Garage Member
    Join Date
    Aug 2012
    Blog Entries
    Virtual environment can be made relocatable by using the following syntax,

    $ virtualenv --relocatable environment_name
    But remember this option has number of issues and doesn't always work. From the official documentation of virtualenv,

    The --relocatable option currently has a number of issues, and is not guaranteed to work in all circumstances. It is possible that the option will be deprecated in a future version of virtualenv.

    Also, this does not make your packages cross-platform. You can move the directory around, but it can only be used on other similar computers.

    So, if you don't have an specific requirement, it's always better to duplicate the virtual environment using the method above descibed by b0nd.

    Anyone who stops learning is old, whether at twenty or eighty. Anyone who
    keeps learning stays young. The greatest thing in life is to keep your mind young.
    - Henry Ford

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts