PIP(Python):ImportError:无法导入名称_remove_dead_weakref
我遇到了错误,我已经搜索了很多,但是找不到很好的解决方法-请任何遇到这种错误并已解决的人.请帮忙.
I am getting below error, I have search lot around but haven't been able to find a good fix- Please anyone who was getting this kind of error and resolved. please help.
File "c:\python27\lib\runpy.py", line 174, in _run_module_as_main
"__main__", fname, loader, pkg_name)
File "c:\python27\lib\runpy.py", line 72, in _run_code
exec code in run_globals
File "C:\python27\Tools\Scripts\pip.exe\__main__.py", line 5, in <module>
File "c:\python27\lib\site-packages\pip\__init__.py", line 5, in <module>
import logging
File "c:\python27\lib\logging\__init__.py", line 26, in <module>
import sys, os, time, cStringIO, traceback, warnings, weakref, collections
File "c:\python27\lib\weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
我很确定此错误的原因是您安装python的方式,并且很可能已复制了您的python从其他位置安装..或重命名文件夹..或环境路径中的python安装无效.
I'm pretty sure the reason for this error is how you're installing python and that you've most likely copied your installation from somewhere else .. or you're renaming folders .. or you've an invalid python installation in your environmental path.
如果您要复制python文件夹,请不要为所有用户"安装它..只需将其安装到仅登录用户"的文件夹中即可.
If you're looking to copy the python folder about, don't install it 'for all users' .. just install it to your folder for your 'logged in user only'.
所以您的解决方案应该是
So your solution should be either
- 再次安装python指向您的位置c:\ python27 或
- 使用仅为此用户安装"安装python.然后将其复制到c:\ python27 ..您可能对pipenv和virtualenv感兴趣(谷歌搜索它们)
- install python again pointing to your location c:\python27 or
- install python using the 'install just for this user' .. then copy from it to your c:\python27 .. you might be interested in pipenv and virtualenv (google search for them)
此外,您可以使用
python -m pip install <module_to_install>
这与运行
pip.exe install <module_to_install>
您可以尝试使用python的完整路径来查看它是否运行pip ok.
例如. c:\python27\python.exe -m pip install <module_to_install>
You could try using the full path for python to see if it runs pip ok.
eg. c:\python27\python.exe -m pip install <module_to_install>