Reputation: 3574
I have an old computer with dozens of old python projects installed, each with its own different virtualenv, and many of which built with different versions of python.
I'd prefer not to have to download these different versions when I create new virtualenvs via virtualenv -p whatever path that version of python has
My question is: within a virtualenv, is there a command I can run to find the path to the version of python which was used to create that particular environment?
For example, if I created a venv with 'virtualenv -p /usr/bin/python3.4' and then ran this command with the venv activated, it would return '/usr/bin/python3.4'
Upvotes: 0
Views: 165
Reputation: 13120
You could try running something like this from the command line:
python -c "import sysconfig; print(sysconfig.get_config_var('BINDIR'))"
Upvotes: 0
Reputation: 2395
Since virtualenv
copies python completely (including the binary) there is no way to know the exact path it originated from.
However, you can easily find the version by running ./python --version
inside the environment's bin
folder.
Upvotes: 1