Python 更新错误“模块”对象不可调用后 pip 不再工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/58451650/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pip no longer working after update error 'module' object is not callable
提问by Agustin
After a pip update, pip has stopped working completely.
pip 更新后,pip 已完全停止工作。
Z:\>pip install matplotlib
Traceback (most recent call last):
File "c:\program files\python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\program files\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Program Files\Python37\Scripts\pip.exe\__main__.py", line 9, in <module>
TypeError: 'module' object is not callable
Any help please?
请问有什么帮助吗?
Edit: I am working on windows 10
编辑:我在 Windows 10 上工作
回答by Toothpick Anemone
All credit for this goes to user han_solo, who left the answer as a comment, instead of as an answer:
这一切归功于用户han_solo,他将答案作为评论而不是作为答案:
Instead of pip install stdlib_list --user
代替 pip install stdlib_list --user
use python -m pip install stdlib_list --user
用 python -m pip install stdlib_list --user
Replace stdlib_list
with matplotlib
or whatever the name is of the package you want.
更换stdlib_list
用matplotlib
或任何名称是您想要的包。
回答by rdemarqui
I've had the same issue as you, and I solved it uninstalling pip and installing again.
我和你有同样的问题,我解决了它卸载 pip 并重新安装。
To uninstall: python -m pip uninstall pip
卸载: python -m pip uninstall pip
To install, follow the instructions: https://www.liquidweb.com/kb/install-pip-windows/
要安装,请按照说明进行操作:https: //www.liquidweb.com/kb/install-pip-windows/
After that you will going to have a older but functional 19.0.3 version.
之后,您将拥有一个较旧但功能强大的 19.0.3 版本。
回答by mudit
If you do not wish to use the long command every time python -m pip install <package>
, reinstall pip to the older version where this error wasn't there.
如果您不想每次都使用长命令python -m pip install <package>
,请将 pip 重新安装到不存在此错误的旧版本。
python -m pip install pip==19.0.3
Now you will be able to use pip install matplotlib
or pip list
normally.
现在您将能够使用pip install matplotlib
或pip list
正常。
And whenever the bug is resolved, upgrade pip like you did before.
每当错误解决时,请像以前一样升级 pip。
回答by Camilo Caquimbo
This worked for me, uninstall pip 19.3.1 and replace with 19.0.3, error gone.
这对我有用,卸载 pip 19.3.1 并替换为 19.0.3,错误消失了。
python -m pip install pip==19.0.3 --user
回答by Piyush Upadhyay
Have the habit of installing any python packages with pip using python -m, say for installing numpyuse below command:
有使用python -m使用 pip 安装任何 python 包的习惯,比如安装numpy使用下面的命令:
python -m pip install numpy
python -m pip 安装 numpy
In case if it errros out with the environment permission error append --user in the same command:
如果它因环境权限错误而出错,请在同一命令中附加 --user :
python -m pip install numpy --user
python -m pip install numpy --user
回答by Alden DelVecchio
Similar to what @han_solo said, but if your running python3, instead of using:
类似于@han_solo 所说的,但如果您正在运行 python3,而不是使用:
python -m pip install stdlib_list --user
python -m pip install stdlib_list --user
try using:
尝试使用:
python3 -m pip install stdlib_list --user
python3 -m pip install stdlib_list --user
回答by Ashkan
I had the same issue with h5py-2.7.1, and the warnings were gone after upgrading to h5py-2.10.0.
我在 h5py-2.7.1 上遇到了同样的问题,升级到 h5py-2.10.0 后警告消失了。
回答by Dmitry Amelin
I cannot leave the comments yet, therefore I've decided to leave a link with an explanation why this can happen: https://github.com/pypa/pip/issues/5599
我还不能留下评论,因此我决定留下一个链接,解释为什么会发生这种情况:https: //github.com/pypa/pip/issues/5599
If this is the case you can try to fix it by downgrading the pip version with the following command:
如果是这种情况,您可以尝试通过使用以下命令降级 pip 版本来修复它:
python -m pip install pip==<previous version>
回答by Michal Sylwester
Had the same problem. I've managed to fix it by reinstalling pip in place, using combination the other answers:
有同样的问题。我设法通过重新安装 pip 来修复它,并结合使用其他答案:
python -m pip install -U --force-reinstall pip
python -m pip install -U --force-reinstall pip