0
爲virtualenv
文檔說,以激活從內部蟒蛇的環境中,使用從運行Python3會話中激活的virtualenv
activate_this = '/path/to/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
但execfile
在Python 3不存在如果我嘗試使用exec(open("venv/bin/activate_this.py").read())
,它抱怨
AssertionError: You must run this like execfile('path/to/activate_this.py', dict(__file__='path/to/activate_this.py'))
這是有道理的,因爲activate_this.py
提到了__file__
。
如何從python 3中激活virtualenv?