3

There is a development directory

/home/user/work/prog

with environment setup with

python3 -m venv .

After finishing development I copied the directory to

/opt/prog

Of course the environment paths inside are all wrong and are still pointing to /home/user/work/prog.

Simply running

python3 -m venv /opt/prog

didn't change the paths to the new location. However, this solution looked good:

python3 -m venv --clear /opt/prog

Unfortunately that removed all the project source files.

I think I am trying to perform a basic ordinary task, but searching I can't even find the same question.

What is the standard way to reset the virt env path information (without removing source) ?

Craig Hicks
  • 2,199
  • 20
  • 35
  • 1
    I am using --clear in order to reset the virtualenv, i.e. remove all packages before a pip install. It removes also the code sometimes. I think it is similar to this question here, i.e. it is no easy way to move, there used to be an option to make the paths relative with --relocatable: https://stackoverflow.com/questions/32407365/can-i-move-a-virtualenv – ionescu77 Mar 27 '19 at 11:13
  • 1
    @ionescu Thanks for that pointer. - I suppose the status quo is that every collection of project files (excluding env) is already managed as a relocatable set of files via git or some other project management software. Therefore one can always 'move' the project files only with 'git', and then setup the new env using the output of the freeze command from the old environment. Any other cases (e.g. some links were manually inserted in the environment) are rare enough to not warrant a special effort. – Craig Hicks Mar 27 '19 at 17:50
  • 1
    I agree, lately I write a bash script which creates a new venv and than does a git clone for the code, then installs requirements needed. – ionescu77 Mar 28 '19 at 09:54

0 Answers0