正确使用 PIP 安装 Python 包 避免 TypeError: ‘module’ object is not callable

在此之前,我一直是这样在 macOS 上安装和使用 pip 的:

后来,这个方法失效了,变成了这样:

终于有一天,pip 提示我它需要更新,于是:

查询后,发现原来 Python 是要这样安装包的:

对于 Python3,依旧使用 pip 而不是 pip3 ,也就是:

 

最后,每次写这么长的命令很麻烦,可以设置一个别名 alias pip="python3 -m pip" 当然还有 alias pip3="python3 -m pip"

对于我来说,我用的是 zsh,于是这个别名就写到 ~/.zshrc 即可。

 

另外,在安装包时使用 --user 参数可以避免权限问题。

本文由 落格博客 原创撰写:落格博客 » 正确使用 PIP 安装 Python 包 避免 TypeError: ‘module’ object is not callable

转载请保留出处和原文链接:https://www.logcg.com/archives/3281.html

About the Author

R0uter

如非声明,本人所著文章均为原创手打,转载请注明本页面链接和我的名字。

Comments

  1. I and my friends happened to be looking through the best ideas found on your web blog while the sudden I had an awful suspicion I never thanked the web site owner for those strategies. Those ladies came for this reason very interested to learn them and already have sincerely been tapping into these things. Many thanks for being quite thoughtful and then for choosing variety of important issues millions of individuals are really needing to learn about. My very own sincere apologies for not saying thanks to you earlier.

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注