【发布时间】:2016-05-28 22:56:23
【问题描述】:
我是 python(和 linux)的新手,我正在尝试运行 setup.py,但是它无法正常工作,因为有一个公司代理阻止了对 pypi 的请求。
我检查了 this link to properly use the setup.py 并检查了 stackoverflow 中的 this 和 this 解决方案,但我无法让它们工作(或者我应用它们的方式有误)。
我正在使用:
- 虚拟环境
- virtualenvwrapper
- python 2.7
- Ubuntu 14
我已经在.profile和.bashrc中添加了http_proxy和https_proxy。
当我使用 pip install --proxy the.proxy:port some_module 时,它工作正常(我也知道 env 变量会做一些事情,因为在此之前我什至无法访问 stackoverflow.com,所以我假设它们工作得很好)。
我已经尝试过的是:
- 尝试在 python 上使用 --proxy
- 在 python 中寻找类似于 --proxy 的东西
- 尝试在我的 setup.py 中添加前面提到的解决方案之一中描述的代理配置(添加到此问题的描述中)
- 使用 pip --proxy 尝试并成功下载了几个模块(这是我目前不太好的解决方案)
- 弄乱 virtualenv 中的 python 配置文件,希望找到一些代理配置
我的 setup.py 文件如下所示:
from setuptools import setup, find_packages
import requests
with open('development.txt') as file:
install_requires = file.readlines()
with open('development_test.txt') as file_test:
test_requires = file_test.readlines()
setup(
name="my_project",
version="1.0.0-SNAPSHOT",
packages=find_packages(),
install_requires=install_requires,
test_suite="nose.collector",
tests_require=test_requires,
)
proxies = {
"http": "http://proxy.myproxy.com:3333",
"https": "http://proxy.myproxy.com:3333",
}
# not sure what goes here... tried a few things but nothing happend
requests.get("https://pypi.python.org", proxies=proxies)
我会尝试任何建议,感谢任何帮助。 谢谢
【问题讨论】:
标签: python-2.7 proxy ubuntu-14.04