Python pip错误:"无法获取索引基URL https://pypi.python.org/simple/"

liz*_*isk 19 python proxy pip

我正在尝试使用pip安装几个软件包.当我使用sudo执行此操作时,会发生此错误:"无法获取索引基本URL https://pypi.python.org/simple/ ".当我执行不带sudo的命令时,包下载成功,但我没有足够的权限.这种不同行为可能是什么原因?我坐在代理人后面.

djc*_*djc 31

也许试试sudo -E:

 -E          The -E (preserve environment) option indicates to the secu?
             rity policy that the user wishes to preserve their existing
             environment variables.  The security policy may return an
             error if the -E option is specified and the user does not
             have permission to preserve the environment.
Run Code Online (Sandbox Code Playgroud)

假设您的代理设置是在普通用户环境中设置的,而不是您运行时获得的设置sudo.

  • @lizarisk`-E`是`sudo`的选项,而不是'pip`.我做了一个编辑来澄清 (3认同)