2

virtualenv allows you to set a specific Python version to use, e.g.:

virtualenv --python=python3.8 venv

I guess that virtualenv takes the selected Python interpreter for the system where it runs so you cannot put whatever you want as value for --python setting.

However, is there any way to know a priori which interpreters you have available (i.e. which values you can use for --python)? Something like virtualenv --list-interpreters (I have had a look in virtualenv --help but I haven't found anything like that).

jonrsharpe
  • 115,751
  • 26
  • 228
  • 437
fgalan
  • 11,732
  • 9
  • 46
  • 89
  • 4
    Not really, because you could have valid interpreters anywhere. Depending on your platform/shell you may be able to list all executables starting with `python` in your path (using `zsh` on macOS I just type "python" and hit Tab twice), but that's potentially not exhaustive (e.g. I see `python3` and `python3.9` that way, but not the `python3.10` in Homebrew's cellar). – jonrsharpe Jan 14 '22 at 13:25
  • Can this question help you? [link](https://stackoverflow.com/q/30464980/11100417) – Hamid Rasti Jan 14 '22 at 13:42
  • @jonrsharpe so basically, if I understand correctly, what `--python` does is a "bypass" of the interpreters found at OS level, right? – fgalan Jan 14 '22 at 15:05
  • It's basically "what should `/bin/python` be a symlink to"? – jonrsharpe Jan 14 '22 at 16:33

0 Answers0