How to use the same Python virtualenv on both Windows and Linux How to use the same Python virtualenv on both Windows and Linux windows windows

How to use the same Python virtualenv on both Windows and Linux


Short answer, NO. But you can share the venv build scripts.

  1. pip freeze all libraries to a requirements.txt file.

    pip freeze > requirements.txt
  2. Create the venv on each OS:

    python -m venv envsource env/bin/activatepip install -r requirements.txt  # Install all the libs.

There are several reasons why venvs cannot be shared across OSes:

  1. Some packages contains C extensions, and the OS' .dlls are not compatible with each other.
  2. venvs contain scripts with hardcoded paths. Windows and Linux paths are different.