0

I moved the venv1 virtual environment's content from a computer into venv2, a virtual environment located in a different computer.

So, on the new computer, when I run cd venv2 and then source bin/activate I noticed this weird behavior on Terminal:

(venv1) me@machine2:~/venv2

I would like to know if someone can explain me why I am not positioned into

(venv2) me@machine2:~/venv2

instead?

Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
  • I'm pretty sure moving a venv to a different machine is not a supported operation. There are lots of ways you could just get a crash instead of any useful behavior. – Daniel Pryden Mar 19 '18 at 09:37
  • Possible duplicate of [Port Python virtualenv to another system](https://stackoverflow.com/questions/17587840/port-python-virtualenv-to-another-system) – phd Mar 19 '18 at 15:18

1 Answers1

1

The activate script does this around line 43:

VIRTUAL_ENV="/full/path/to/venv1"
export VIRTUAL_ENV

_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH

# unset PYTHONHOME if set
if ! [ -z "${PYTHONHOME+_}" ] ; then
    _OLD_VIRTUAL_PYTHONHOME="$PYTHONHOME"
    unset PYTHONHOME
fi

if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT-}" ] ; then
    _OLD_VIRTUAL_PS1="$PS1"
    if [ "x" != x ] ; then
        PS1="$PS1"
    else
        PS1="(`basename \"$VIRTUAL_ENV\"`) $PS1"
    fi
    export PS1
fi

so it will still look (and show it in your prompt) for the original venv1 directory. Unless your machine2 has the same directory tree things will not work.

agnul
  • 12,608
  • 14
  • 63
  • 85