virtualenv 下 getsitepackages 的问题

gup*_*tam 5 python terminal virtualenv

我想检查在我的虚拟环境下运行的是哪个 Python 解释器,所以我刚刚进入了 virtualenv 并使用了 getsitepackages。这是出来的。

(test)~/Documents/Development/test$ python
Python 2.7.9 (default, Apr  7 2015, 07:58:25) 
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>> print site.getsitepackages()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'getsitepackages'
>>>
Run Code Online (Sandbox Code Playgroud)

在 virtualenv 下运行时,这是正常行为吗?如果可能,我将如何纠正,或者我什至应该打扰?

tja*_*ati 3

有个用户和你有同样的问题

有一个已知的错误,即Python 2.7 与site.py. 自 2012 年 11 月以来,此错误仍然存​​在。

您必须离开 virtualenv 或使用其他版本的 Python。