python 中出现的AttributeError: 'module' object has no attribute '_handlerList'

Traceback (most recent call last):

  File "/usr/local/bin/pip", line 9, in <module>

    load_entry_point('pip==9.0.1', 'console_scripts', 'pip')()

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/__init__.py", line 233, in main

    return command.main(cmd_args)

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 185, in main

    for name in ["pip._vendor", "distlib", "requests", "urllib3"]

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/compat/dictconfig.py", line 565, in dictConfig

    dictConfigClass(config).configure()

  File "/Library/Python/2.7/site-packages/pip-9.0.1-py2.7.egg/pip/compat/dictconfig.py", line 332, in configure

    del logging._handlerList[:]

AttributeError: 'module' object has no attribute '_handlerList'

 

一.pip 版本升级造成的原因

升级过后会有 logging-0.4.9.6的在你的/Library/Python/2.7/site-packages/文件夹下的,删除即可。

二.easy_install 的logging文件

若是前面第一步完成后还没有解决,继续查看下一步即可,亲

logging文件也是在/Library/Python/2.7/site-packages/文件夹下

@Aarushi-Ign You shouldn't have any logging-0.4.9.6, or easy_install logging. The logging module is part of the standard library. What seems to be happening is that your 3rd-party logging module is overriding the stdlib version (that's a fault of easy_install, which puts 3rd party modules ahead of the standard library in PYTHONPATH).

Try uninstalling all 3rd party logging modules, and that should fix your issue.

这是翻墙看到的解决方案。

链接:https://github.com/pypa/pip/issues/3193

 

若是你还有其他更好解决的方法,或者疑问,请留言。谢谢亲

原文地址:https://www.cnblogs.com/Hondsome/p/6077178.html