【发布时间】:2014-11-04 04:55:20
【问题描述】:
这里是re.py的内容:
import re
if re.search('test', 'test'): print 'match'
当我运行$ python re.py 时,输出显然是match。但是当我激活 virtualenv 并尝试再次运行脚本时,我得到:
...
if re.search('test', 'test'): print 'match'
AttributeError: 'module' object has no attribute 'search'
以下是 virtualenv 未激活时 Python 解释器的输出:
$ python
Python 2.7.5 (default, Jun 3 2013, 17:42:22)
[GCC 4.2.1 Compatible Apple Clang 4.0 ((tags/Apple/clang-421.0.57))] on darwin
这是激活时的输出:
$ python
Python 2.7.6 (default, Sep 9 2014, 15:04:36)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.39)] on darwin
为什么在 virtualenv 中使用 Python 2.7.5 时 re 模块会中断?
【问题讨论】:
标签: python regex python-2.7 virtualenv virtualenvwrapper