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.g4h@gmail.com b0nd's Avatar
    Join Date
    Jul 2010
    Location
    irc.freenode.net #g4h
    Posts
    744

    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.

    Cheers!
    [*] 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
    Location
    India
    Posts
    97
    Blog Entries
    1
    Virtual environment can be made relocatable by using the following syntax,

    Code:
    $ 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.
    Source: http://virtualenv.readthedocs.org/en...ts-relocatable

    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.

    Regards,
    c0dist
    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
  •