我尝试了这个命令。
pip install --proxy="username:password@192.168.1.1:3128" packagename
错误信息显示:
Traceback (most recent call last):
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-1.5.5-py3.5.egg/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-1.5.5-py3.5.egg/pip/commands/install.py", line 278, in run
requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-1.5.5-py3.5.egg/pip/req.py", line 1177, in prepare_files
url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-1.5.5-py3.5.egg/pip/index.py", line 194, in find_requirement
page = self._get_page(main_index_url, req)
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-1.5.5-py3.5.egg/pip/index.py", line 568, in _get_page
session=self.session,
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-1.5.5-py3.5.egg/pip/index.py", line 670, in get_page
resp = session.get(url, headers={"Accept": "text/html"})
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-1.5.5-py3.5.egg/pip/_vendor/requests/sessions.py", line 395, in get
return self.request('GET', url, **kwargs)
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-1.5.5-py3.5.egg/pip/download.py", line 237, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-1.5.5-py3.5.egg/pip/_vendor/requests/sessions.py", line 383, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-1.5.5-py3.5.egg/pip/_vendor/requests/sessions.py", line 486, in send
r = adapter.send(request, **kwargs)
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-1.5.5-py3.5.egg/pip/_vendor/requests/adapters.py", line 305, in send
conn = self.get_connection(request.url, proxies)
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-1.5.5-py3.5.egg/pip/_vendor/requests/adapters.py", line 206, in get_connection
except_on_missing_scheme(proxy)
File "/usr/local/python3.5/lib/python3.5/site-packages/pip-1.5.5-py3.5.egg/pip/_vendor/requests/utils.py", line 631, in except_on_missing_scheme
raise MissingSchema('Proxy URLs must have explicit schemes.')
pip._vendor.requests.exceptions.MissingSchema: Proxy URLs must have explicit schemes.
顺便提一下,我记得如果用户名或密码中有像"."这样的标点符号,必须替换为其他字符,但我忘了是什么。有人能提醒我一下吗?谢谢!
http_proxy
和https_proxy
。 - pkuphy代理URL必须有明确的方案
,因此你需要运行pip install --proxy="http://username:password@192.168.1.1:3128" packagename
。注意添加了http://
。 - pkuphy