Python pip install(使用代理)无法解析 VPN 后面的 VM 中的服务器

标签 python ubuntu proxy pip vpn

我的设置:

  • 企业网络上的 Windows 7 64 位主机
  • Ubuntu 12.04 64 位 VirtualBox guest
    • 使用 VirtualBox 桥接适配器配置的 Ubuntu 客户机
    • 代理设置确认有效:Firefox 可以访问公司内部网站和互联网,apt-get install效果也不错

这是到目前为止我为配置代理所做的工作:

/etc/profile.d/proxy.sh:

export http_proxy="http://<my_proxy>:<my_port>"
export https_proxy="http://<my_proxy>:<my_port>"
export ftp_proxy="http://<my_proxy>:<my_port>"

为了获得工作能力,修改/etc/apt/apt.conf.d/01proxy:

Acquire::http::Proxy “http://<my_proxy>:<my_port>"

为了在使用 sudo 时保留环境变量,修改/etc/sudoers.d/proxy:

Defaults env_keep += "http_proxy https_proxy ftp_proxy"

我还在“设置”->“网络”->“网络代理”中设置了 HTTP/HTTPS/FTP 代理设置,然后单击“在系统范围内应用”。

问题是当我尝试 pip install (有或没有 sudo ),它失败并出现错误:

$ pip -vv install git-review
Downloading/unpacking git-review
  Getting page http://pypi.python.org/simple/git-review
  Could not fetch URL http://pypi.python.org/simple/git-review: <urlopen error [Errno -2] Name or service not known>
  Will skip URL http://pypi.python.org/simple/git-review when looking for download links for git-review
  Getting page http://pypi.python.org/simple/
  Could not fetch URL http://pypi.python.org/simple/: <urlopen error [Errno -2] Name or service not known>
  Will skip URL http://pypi.python.org/simple/ when looking for download links for git-review
  Cannot fetch index base URL http://pypi.python.org/simple/
  URLs to search for versions for git-review:
  * http://pypi.python.org/simple/git-review/
  Getting page http://pypi.python.org/simple/git-review/
  Could not fetch URL http://pypi.python.org/simple/git-review/: <urlopen error [Errno -2] Name or service not known>
  Will skip URL http://pypi.python.org/simple/git-review/ when looking for download links for git-review
  Could not find any downloads that satisfy the requirement git-review
No distributions at all found for git-review
Exception information:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 126, in main
    self.run(options, args)
  File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 223, in run
    requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
  File "/usr/lib/python2.7/dist-packages/pip/req.py", line 948, in prepare_files
    url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
  File "/usr/lib/python2.7/dist-packages/pip/index.py", line 152, in find_requirement
    raise DistributionNotFound('No distributions at all found for %s' % req)
DistributionNotFound: No distributions at all found for git-review

我试过使用 --proxy 选项(--proxy=http://<my_proxy>:<my_port> 带/不带 = 号,带/不带引号),但即使这样也会显示相同的错误。

我也尝试过如下设置 .pip/pip.conf:

[global]
timeout = 60
proxy = http://<my_proxy>:<my_port>

作为另一个数据 pip ,如果有帮助,nslookup从命令行对企业内部网外部的域失败,但对内部域有效。然而,如前所述,Firefox 和 apt-get 似乎没有使用代理解析域名的问题。

有什么想法吗? 谢谢!

最佳答案

这是由 2014 年 6 月解决的 pip 错误引起的

https://github.com/pypa/pip/issues/1104

关于Python pip install(使用代理)无法解析 VPN 后面的 VM 中的服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23699968/

相关文章:

python 无法使用 virtualenv

python - 如何在 PyQt5 中对齐 QLabel 上的中心图像?

python - 如何匹配多列并查找pandas中的特定列值?

python - 如何在 Django 中序列化后构建对象

python - 无法在 Scrapy 项目中使用代理

java - apache httpclient 使用 https 代理 : peer not authenticated

linux - 为什么我的寄存器常量比较在 NASM Assembly 中不起作用?

java - 即使已经安装了新版本,Eclipse 中也会出现旧的 JRE 版本错误

linux - OpenShift 中的 vsts-agent

javascript - 如何获取 node-http-proxy 完成的每个代理请求的响应时间?