Ultimately, it seems that your question is really about how to determine if running Python is running in virtualenv. To understand this, we must understand how it works virtualenv.
When you run the activatescript inside virtualenv, it performs two functions:
PATH, bin virtualenv, python virtualenv.VIRTUAL_ENV, script .
python virtualenv, python VIRTUAL_ENV. , python , .
, sys sys.prefix. , virtualenv , Python, , .
Python virtualenv : sys real_prefix, , Python, , , Python , , virtualenv:
import sys
if getattr(sys, "real_prefix", None) is not None:
print "Maybe in a virtualenv"
else:
print "Probably not in a virtualenv"
. , python , . , /usr/share/man - (, ) , :
Python , - /home/johnd/local-python, real_prefix , Python lib , , /etc /usr/share/man
, /usr/lib/python2.7 , Python, .
, , , , data_files , virtualenv. , , , , . , , , virtualenv, .