我的设置:
- 企业网络上的 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 错误引起的
关于Python pip install(使用代理)无法解析 VPN 后面的 VM 中的服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23699968/