Skip to content
Advertisement

how can I find out which python virtual environment I am using?

I have several virtual environment in my computer and sometimes I am in doubt about which python virtual environment I am using. Is there an easy way to find out which virtual environment I am connected to?

Advertisement

Answer

You can use sys.prefix to determine which virtualenv you’re in.

import sys
print(sys.prefix)

from the sys docs

A string giving the site-specific directory prefix where the platform independent Python files are installed

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement