Python标准库在virtualenv中不起作用

Python标准库在virtualenv中不起作用,python,regex,python-2.7,virtualenv,virtualenvwrapper,Python,Regex,Python 2.7,Virtualenv,Virtualenvwrapper,以下是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' 以下是virtua

以下是
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中使用Python2.7.5时,为什么
re
模块会中断?

问题是
re
内部模块和
re.py
模块混合在一起


请将您的文件名更改为
re_example.py
,然后再试。

效果很好,谢谢。但为什么virtualenv很重要呢?我必须检查一下,但决不将文件名指定为python内置模块。