服务是centos6,默认python是2.6的。安装完virtualenvwrapper执行source /usr/bin/virtualenvwrapper.sh初始化时出现如下错误:
Traceback (most recent call last): File "/usr/lib64/python2.6/runpy.py", line 122, in _run_module_as_main "__main__", fname, loader, pkg_name) File "/usr/lib64/python2.6/runpy.py", line 34, in _run_code exec code in run_globals File "/usr/lib/python2.6/site-packages/virtualenvwrapper/hook_loader.py", line 16, in <module> from stevedore import ExtensionManager File "/usr/lib/python2.6/site-packages/stevedore/__init__.py", line 23, in <module> LOG.addHandler(logging.NullHandler()) AttributeError: 'module' object has no attribute 'NullHandler' virtualenvwrapper.sh: There was a problem running the initialization hooks.
原因python2.6的loggin模块没有NullHandler.解决方法如下:
修改
/usr/lib/python2.6/site-packages/stevedore/__init__.py
将最后一行的LOG.addHandler(logging.NullHandler())内容改为:
try: from logging import NullHandler except ImportError: class NullHandler(logging.Handler): def emit(self, record): pass LOG.addHandler(NullHandler())
摘抄于该链接:http://www.loonapp.com/blog/48/