2015-02-06 61 views
0

我在Yosemite(10.10.2)上運行Python 2.7.9,並且我的pip安裝出錯了。 我可以使用get-pip.py不再安裝PIP:嘗試使用pip安裝時出現AttributeError

sth:~ $ sudo python get-pip.py 
Traceback (most recent call last): 
    File "get-pip.py", line 20204, in <module> 
    main() 
    File "get-pip.py", line 152, in main 
    bootstrap(tmpdir=tmpdir) 
    File "get-pip.py", line 130, in bootstrap 
    sys.exit(pip.main(["install", "--upgrade"] + packages + args)) 
    File "/tmp/tmpdUeSSr/pip.zip/pip/__init__.py", line 217, in main 

    File "/tmp/tmpdUeSSr/pip.zip/pip/basecommand.py", line 183, in main 
    File "/tmp/tmpdUeSSr/pip.zip/pip/compat/dictconfig.py", line 565, in dictConfig 
    File "/tmp/tmpdUeSSr/pip.zip/pip/compat/dictconfig.py", line 332, in configure 
AttributeError: 'module' object has no attribute '_handlerList' 

我可以使用easy_install,然後在/usr/local/bin創建符號鏈接到它,而是試圖用它給了我同樣的錯誤安裝,隨後:

sth:~ $ sudo pip install twine 
Traceback (most recent call last): 
    File "/usr/local/bin/pip", line 9, in <module> 
    load_entry_point('pip==6.0.8', 'console_scripts', 'pip')() 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.8-py2.7.egg/pip/__init__.py", line 217, in main 
    return command.main(cmd_args) 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.8-py2.7.egg/pip/basecommand.py", line 183, in main 
    for name in ["pip._vendor", "distlib", "requests", "urllib3"] 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.8-py2.7.egg/pip/compat/dictconfig.py", line 565, in dictConfig 
    dictConfigClass(config).configure() 
    File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.8-py2.7.egg/pip/compat/dictconfig.py", line 332, in configure 
    del logging._handlerList[:] 
AttributeError: 'module' object has no attribute '_handlerList' 

我敢肯定它不是用PIP問題,所以想知道我做錯了......

+0

看來由於某種原因,你的'logging'模塊已經過時了。通過'import logging;檢查你的版本;打印 logging .__ version__'。如果它已經過期,請運行'easy_install logging'。 – dmg 2015-02-06 12:56:41

回答

0

當年我得到一個類似的錯誤一小時前,發現了這個問題。 但是我剛剛解決了它。 雖然你可能不認爲它有用,但我希望這個答案能幫助你解決問題。

事實上,當我用virtualenvwrapper,我想突然控制一個ENV。 因此,我在的原因中創建了一個備份目錄,在另一個ENV所在的同一目錄中。

之後,不僅有2個ENVs,還有3個與ENV有關的目錄在.virtualenv。 它使站點包的一些路徑,等等顯然改變helter-skelter。

這就是爲什麼,如果你不確認關於Virtualenv的文件,我建議你這樣做。

與我的錯誤如下。

~ pip freeze 
Traceback (most recent call last): 
    File "/usr/local/bin/pip", line 9, in <module> 
    load_entry_point('pip==6.0.6', 'console_scripts', 'pip')() 
    File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.6-py2.7.egg/pip/__init__.py", line 217, in main 
    return command.main(cmd_args) 
    File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.6-py2.7.egg/pip/basecommand.py", line 183, in main 
    for name in ["pip._vendor", "distlib", "requests", "urllib3"] 
    File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.6-py2.7.egg/pip/compat/dictconfig.py", line 565, in dictConfig 
    dictConfigClass(config).configure() 
    File "/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pip-6.0.6-py2.7.egg/pip/compat/dictconfig.py", line 332, in configure 
    del logging._handlerList[:] 
AttributeError: 'module' object has no attribute '_handlerList' 
3

對不起necroing但對於其他的Google的緣故:

正如指出的here,你應該pip,因爲它打亂了系統版本上安裝logging。我不確定這是什麼時候改變的。

因此刪除yourpythoninstallpath/lib/python2.7/site-packages/logging應該刪除錯誤。