pip安装常出现的错误及解决方案

1. Read timed out 超时问题

在这里插入图片描述
一般windows系统出现这个问题,可以在命令后面加上--user参数,类似:

pip install pyinstaller 
# 上句报超时错误
pip install pyinstaller --user
# 一般就可以下载了
  1. 使用–help去查看–user的作用
    在这里插入图片描述
    大意就是:把这个包换个地方安装

  1. 参考:安装私有的包

问题

你想要安装一个第三方包,但是没有权限将它安装到系统Python库中去。 或者,你可能想要安装一个供自己使用的包,而不是系统上面所有用户。

解决方案

Python有一个用户安装目录,通常类似”~/.local/lib/python3.3/site-packages”。 要强制在这个目录中安装包,可使用安装选项“–user”。例如:

python3 setup.py install --user

或者

pip install --user packagename

在sys.path中用户的“site-packages”目录位于系统的“site-packages”目录之前。 因此,你安装在里面的包就比系统已安装的包优先级高 (尽管并不总是这样,要取决于第三方包管理器,比如distribute或pip)。


  1. 参考Stack Overflow:What is the purpose of “pip install --user …”?

pip defaults to installing Python packages to a system directory (such as /usr/local/lib/python3.4). This requires root access.
--user makes pip install packages in your home directory instead, which doesn’t require any special privileges.

大意就是:pip会把python包默认安装到一个系统目录,类似XXX,使用–user参数可以把这些包安装到属于当前用户的一个目录,就不会需要特殊的权限


2. Installing build dependencies error安装构建依赖错误

在这里插入图片描述
一般这种都是因为缺乏一些依赖包导致的,可以考虑直接使用conda安装,

conda install pyinstaller 

3. 关于 conda-forge

经常可以在一些github的python包安装上看到这个词,常见用法,例如:

conda install -c conda-forge pyinstaller
# 这个速度非常快,真的是飞起来! 以后出问题就有这个安装方式,贼6

在这里插入图片描述
其实,这个是一个channel,就好像以前的清华镜像channel一样。参考其官网:A brief introduction¶
在这里插入图片描述
就是一个提供安装包镜像的channel,感谢!

猜你喜欢

转载自blog.csdn.net/Castlehe/article/details/112280903