0

I have questions regarding how virtual environment work. here is what I did:

  1. I created a python virtual environment on the network drive at \networkdrive_path\python_venv using computer A.

  2. on computer B, in the windows command window, I activate the virtual environment, however, after activation, when I type "python", it's not open python.exe in the virtual environment, but it's looking for python.exe in the path that stored in the "Home" variable in the pyvenv.cfg.

My question is: why it's searching python.exe in the path that stored in the "Home" variable in the pyvenv.cfg, instead of directly use python.exe in the \networkdrive_path\python_venv\scripts?

the "home" variable stores the python path that I used to create virtual environment on computer A. when I change the home path to the python path in computer B, it works when I type "Python" after activation.

sinoroc
  • 18,409
  • 2
  • 39
  • 70
Z.Gary
  • 13
  • 1
  • 4
  • 1
    The answer is: this is how virtual environments work. A virtual environment needs access to the Python interpreter used to create it (the virtual environment). And beware of changing paths in `pyvenv.cfg`, I really am not sure it is supported, things might break. And generally virtual environments are not meant to be shared, moved, renamed. If you know what you are doing then you can go around that of course, but it is not intended usage. – sinoroc Mar 08 '23 at 08:45
  • Normally virtual environments are not portable and are tied to the interpreter they were created with. If you need portable python on Windows, look at [WinPython](https://winpython.github.io/), for example. – Niko Föhr Mar 08 '23 at 08:51

0 Answers0