Last active
March 22, 2022 00:57
-
-
Save avcaliani/c812d78dfa21d301e21adb55787ae818 to your computer and use it in GitHub Desktop.
#python #check-if-in-venv
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import platform | |
import sys | |
if __name__ == '__main__': | |
py_version = platform.python_version() | |
prefix = sys.prefix | |
base_prefix = sys.base_prefix if py_version.startswith('3') else sys.exec_prefix | |
print('------------< venv checker >------------') | |
print('Python Version.: {}'.format(py_version)) | |
print('Prefix.........: {}'.format(prefix)) | |
print('Base Prefix....: {}'.format(base_prefix)) | |
if prefix == base_prefix: | |
print('you ARE NOT using a venv!') | |
else: | |
print('you ARE using a venv \\o/') | |
print('----------------< end >-----------------') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment