how to pip install with proxy - python

I tried this command
pip install --proxy="username:password#192.168.1.1:3128" packagename
and the error message say:
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.
By the way, I remember if the username or password has the interpunction like "." it must be replaced with something but I forget about that. Can anyone remind me of that? Thanks!

I was struggling with this issue too. After many expeiments with pip and easy_install proxy settings I give up and donwloaded whl files from here.
and install them:
pip install SomePackage-1.0-py2.py3-none-any.whl

Related

Can't pip install from a url

I'm trying to pip install pip install -i https://pypi.anaconda.org/lapu/simple fix-yahoo-finance but every time I do so, a whole bunch of red text comes out and I don't know what I'm doing wrong. I'm using Windows and Anaconda, I've already installed pip prior to this. Any advice?
The error is as follows:
Exception:
Traceback (most recent call last):
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_internal\cli\base_command.py", line 143, in main
status = self.run(options, args)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_internal\commands\install.py", line 318, in run
resolver.resolve(requirement_set)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_internal\resolve.py", line 102, in resolve
self._resolve_one(requirement_set, req)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_internal\resolve.py", line 256, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_internal\resolve.py", line 209, in _get_abstract_dist_for
self.require_hashes
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_internal\operations\prepare.py", line 218, in prepare_linked_requirement
req.populate_link(finder, upgrade_allowed, require_hashes)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_internal\req\req_install.py", line 164, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_internal\index.py", line 572, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_internal\index.py", line 530, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_internal\index.py", line 675, in _get_pages
page = self._get_page(location)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_internal\index.py", line 793, in _get_page
return _get_html_page(link, session=self.session)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_internal\index.py", line 144, in _get_html_page
"Cache-Control": "max-age=0",
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_vendor\requests\sessions.py", line 525, in get
return self.request('GET', url, **kwargs)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_internal\download.py", line 396, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_vendor\requests\sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_vendor\requests\sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_vendor\cachecontrol\adapter.py", line 53, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_vendor\requests\adapters.py", line 410, in send
conn = self.get_connection(request.url, proxies)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_vendor\requests\adapters.py", line 304, in get_connection
proxy_url = parse_url(proxy)
File "C:\Users\Cecilia\Anaconda3\lib\site-packages\pip\_vendor\urllib3\util\url.py", line 199, in parse_url
raise LocationParseError(url)
pip._vendor.urllib3.exceptions.LocationParseError: Failed to parse: host:port
Have you tried installing like specified on the Github page ?
$ pip install fix_yahoo_finance --upgrade --no-cache-dir

kali linux pip install paramiko get ValueError

when I install paramiko with pip get error
ValueError: Unable to determine SOCKS version from socks://127.0.0.1:1080/
This is the detailed error code I get:
root#kali-linux:~# pip install paramiko
Collecting paramiko
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 335, in run
wb.build(autobuilding=True)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 554, in _prepare_file
require_hashes
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/req/req_install.py", line 278, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/index.py", line 568, in _get_pages
page = self._get_page(location)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/index.py", line 792, in get_page
"Cache-Control": "max-age=600",
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/sessions.py", line 488, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/download.py", line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/cachecontrol/adapter.py", line 47, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/adapters.py", line 390, in send
conn = self.get_connection(request.url, proxies)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/adapters.py", line 290, in get_connection
proxy_manager = self.proxy_manager_for(proxy)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/adapters.py", line 184, in proxy_manager_for
**proxy_kwargs
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/packages/urllib3/contrib/socks.py", line 154, in __init__
"Unable to determine SOCKS version from %s" % proxy_url
ValueError: Unable to determine SOCKS version from socks://127.0.0.1:1080/
And I don't what to do then I try to upgrade pip
pip install --upgrade pip
get error prompt code
root#kali-linux:~# pip install --upgrade pip
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/basecommand.py", line 215, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/commands/install.py", line 335, in run
wb.build(autobuilding=True)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 380, in prepare_files
ignore_dependencies=self.ignore_dependencies))
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 487, in _prepare_file
req_to_install, finder)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/req/req_set.py", line 428, in _check_skip_installed
req_to_install, upgrade_allowed)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/index.py", line 465, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/index.py", line 423, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/index.py", line 568, in _get_pages
page = self._get_page(location)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/index.py", line 792, in get_page
"Cache-Control": "max-age=600",
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/sessions.py", line 488, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/download.py", line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/sessions.py", line 596, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/cachecontrol/adapter.py", line 47, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/adapters.py", line 390, in send
conn = self.get_connection(request.url, proxies)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/adapters.py", line 290, in get_connection
proxy_manager = self.proxy_manager_for(proxy)
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/adapters.py", line 184, in proxy_manager_for
**proxy_kwargs
File "/usr/local/lib/python2.7/dist-packages/pip-9.0.1-py2.7.egg/pip/_vendor/requests/packages/urllib3/contrib/socks.py", line 154, in __init__
"Unable to determine SOCKS version from %s" % proxy_url
ValueError: Unable to determine SOCKS version from socks://127.0.0.1:1080/
I use the command
set | grep -i all_proxy
get the prompt code
ALL_PROXY=socks://127.0.0.1:1080/
all_proxy=socks://127.0.0.1:1080/
what should I do?
export all_proxy="socks5://127.0.0.1:1080"
export ALL_PROXY="socks5://127.0.0.1:1080"
if you don't want a proxy:
export all_proxy=""
export ALL_PROXY=""

"AttributeError: 'NoneType'" shows up everytime I use pip

I can install wheels but can't use "pip install 'module'", its like I just can't install those modules from the Internet.
Error
AttributeError: 'NoneType' object has no attribute 'startswith'
In spite of tensorflow, usual modules like "requests" or "numpy" can't be installed by pip.
C:\Users\Think>pip install tensorflow
Collecting tensorflow
Exception:
Traceback (most recent call last):
File "D:\Anaconda3\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "D:\Anaconda3\lib\site-packages\pip\commands\install.py", line 335, in
run
wb.build(autobuilding=True)
File "D:\Anaconda3\lib\site-packages\pip\wheel.py", line 749, in build
self.requirement_set.prepare_files(self.finder)
File "D:\Anaconda3\lib\site-packages\pip\req\req_set.py", line 380, in
prepare_files
ignore_dependencies=self.ignore_dependencies))
File "D:\Anaconda3\lib\site-packages\pip\req\req_set.py", line 554, in
_prepare_file
require_hashes
File "D:\Anaconda3\lib\site-packages\pip\req\req_install.py", line 278, in
populate_link
self.link = finder.find_requirement(self, upgrade)
File "D:\Anaconda3\lib\site-packages\pip\index.py", line 465, in
find_requirement
all_candidates = self.find_all_candidates(req.name)
File "D:\Anaconda3\lib\site-packages\pip\index.py", line 423, in
find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "D:\Anaconda3\lib\site-packages\pip\index.py", line 568, in _get_pages
page = self._get_page(location)
File "D:\Anaconda3\lib\site-packages\pip\index.py", line 683, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "D:\Anaconda3\lib\site-packages\pip\index.py", line 792, in get_page
"Cache-Control": "max-age=600",
File "D:\Anaconda3\lib\site-packages\pip\_vendor\requests\sessions.py", line
488, in get
return self.request('GET', url, **kwargs)
File "D:\Anaconda3\lib\site-packages\pip\download.py", line 386, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "D:\Anaconda3\lib\site-packages\pip\_vendor\requests\sessions.py", line
475, in request
resp = self.send(prep, **send_kwargs)
File "D:\Anaconda3\lib\site-packages\pip\_vendor\requests\sessions.py", line
596, in send
r = adapter.send(request, **kwargs)
File "D:\Anaconda3\lib\site-packages\pip\_vendor\cachecontrol\adapter.py",
line 47, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "D:\Anaconda3\lib\site-packages\pip\_vendor\requests\adapters.py",
line 423, in send
timeout=timeout
File "D:\Anaconda3\lib\site-
packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line
589, in urlopen
self._prepare_proxy(conn)
File "D:\Anaconda3\lib\site-
packages\pip\_vendor\requests\packages\urllib3\connectionpool.py", line
797, in _prepare_proxy
conn.connect()
File "D:\Anaconda3\lib\site-
packages\pip\_vendor\requests\packages\urllib3\connection.py", line
254, in connect
conn = self._new_conn()
File "D:\Anaconda3\lib\site-
packages\pip\_vendor\requests\packages\urllib3\connection.py", line
142, in _new_conn
(self.host, self.port), self.timeout, **extra_kw)
File "D:\Anaconda3\lib\site-
packages\pip\_vendor\requests\packages\urllib3\util\connection.py",
line 66, in create_connection
if host.startswith('['):
AttributeError: 'NoneType' object has no attribute 'startswith'
I'd appreciate if you could see the image:
Did you follow the steps required for Anaconda installation of tensorflow through pip. It seems to be more elaborate that just pip install tensorflow:
https://www.tensorflow.org/versions/r0.12/get_started/os_setup#anaconda_installation
To whom it may concern, there is this duplicate post, where the OP commented a solution to this problem was found:
Resolved duplicate
It would seem, your python path "D:\Anaconda3" might have something to do with errors using pip install. Try to install python on "C:\".
I had the same problem with pip. It turned out to be an incorrectly formatted url for my proxy where I incorrectly used only one forward slash:
http:/myproxy...
After correcting the above to a working url, everything works.

Raspberry pi - get-pip.py error

I'm working on a Raspberry pi 2 with piface. I'm trying to install openCV by following this steps : click here. When I try doing the step 6 (install pip), I got the following error :
pi#raspberrypi ~ $ sudo python get-pip.py
Exception:
Traceback (most recent call last):
File "/tmp/tmpxtbKBh/pip.zip/pip/basecommand.py", line 211, in main
status = self.run(options, args)
File "/tmp/tmpxtbKBh/pip.zip/pip/commands/install.py", line 305, in run
wb.build(autobuilding=True)
File "/tmp/tmpxtbKBh/pip.zip/pip/wheel.py", line 705, in build
self.requirement_set.prepare_files(self.finder)
File "/tmp/tmpxtbKBh/pip.zip/pip/req/req_set.py", line 334, in prepare_files
functools.partial(self._prepare_file, finder))
File "/tmp/tmpxtbKBh/pip.zip/pip/req/req_set.py", line 321, in _walk_req_to_install
more_reqs = handler(req_to_install)
File "/tmp/tmpxtbKBh/pip.zip/pip/req/req_set.py", line 409, in _prepare_file
req_to_install, finder)
File "/tmp/tmpxtbKBh/pip.zip/pip/req/req_set.py", line 365, in _check_skip_installed
finder.find_requirement(req_to_install, self.upgrade)
File "/tmp/tmpxtbKBh/pip.zip/pip/index.py", line 486, in find_requirement
all_versions = self._find_all_versions(req.name)
File "/tmp/tmpxtbKBh/pip.zip/pip/index.py", line 404, in _find_all_versions
index_locations = self._get_index_urls_locations(project_name)
File "/tmp/tmpxtbKBh/pip.zip/pip/index.py", line 378, in _get_index_urls_locations
page = self._get_page(main_index_url)
File "/tmp/tmpxtbKBh/pip.zip/pip/index.py", line 818, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/tmp/tmpxtbKBh/pip.zip/pip/index.py", line 928, in get_page
"Cache-Control": "max-age=600",
File "/tmp/tmpxtbKBh/pip.zip/pip/_vendor/requests/sessions.py", line 477, in get
return self.request('GET', url, **kwargs)
File "/tmp/tmpxtbKBh/pip.zip/pip/download.py", line 373, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/tmp/tmpxtbKBh/pip.zip/pip/_vendor/requests/sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "/tmp/tmpxtbKBh/pip.zip/pip/_vendor/requests/sessions.py", line 573, in send
r = adapter.send(request, **kwargs)
File "/tmp/tmpxtbKBh/pip.zip/pip/_vendor/cachecontrol/adapter.py", line 46, in send
resp = super(CacheControlAdapter, self).send(request, **kw)
File "/tmp/tmpxtbKBh/pip.zip/pip/_vendor/requests/adapters.py", line 370, in send
timeout=timeout
File "/tmp/tmpxtbKBh/pip.zip/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 544, in urlopen
body=body, headers=headers)
File "/tmp/tmpxtbKBh/pip.zip/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 344, in _make_request
self._raise_timeout(err=e, url=url, timeout_value=conn.timeout)
File "/tmp/tmpxtbKBh/pip.zip/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 314, in _raise_timeout
if 'timed out' in str(err) or 'did not complete (read)' in str(err): # Python 2.6
TypeError: __str__ returned non-string (type Error)
I tried to do the step 7 but I got the barely the same message (install virtualenv) :
Exception:
Traceback (most recent call last):
File "/usr/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/lib/python2.7/dist-packages/pip/commands/install.py", line 290, 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 1178, in prepare_files
url = finder.find_requirement(req_to_install, upgrade=self.upgrade)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 194, in find_requirement
page = self._get_page(main_index_url, req)
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 568, in _get_page
session=self.session,
File "/usr/lib/python2.7/dist-packages/pip/index.py", line 694, in get_page
req, link, "connection error: %s" % exc, url,
TypeError: __str__ returned non-string (type Error)
Storing debug log for failure in /root/.pip/pip.log
I'm trying to solve this problem since 2 days, so if anyone can help me...
Please.
Don't hesitate if you need more information. I also need to apologize for my english, I'm a swiss student...

Google GMail API `installed` app shows IOError 13 from module SSL.py w/o sudo

I am playing around with GMAIL API to create an app to send auto emails from my server. Running my application as a simple user has the following results:
pankgeorg#snf-25181:~/tomotech/gmailer$ python mailer.py
Traceback (most recent call last):
File "mailer.py", line 36, in <module>
gmail_service = build('gmail', 'v1', http=http)
File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.4.5-py2.7.egg/oauth2client/util.py", line 135, in positional_wrapper
File "/usr/local/lib/python2.7/dist-packages/google_api_python_client-1.3.1-py2.7.egg/googleapiclient/discovery.py", line 198, in build
File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.4.5-py2.7.egg/oauth2client/util.py", line 135, in positional_wrapper
File "/usr/local/lib/python2.7/dist-packages/oauth2client-1.4.5-py2.7.egg/oauth2client/client.py", line 547, in new_request
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py", line 1593, in request
(response, content) = self._request(conn, authority, uri, request_uri, method, body, headers, redirections, cachekey)
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py", line 1335, in _request
(response, content) = self._conn_request(conn, request_uri, method, body, headers)
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py", line 1257, in _conn_request
conn.connect()
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py", line 1021, in connect
self.disable_ssl_certificate_validation, self.ca_certs)
File "/usr/local/lib/python2.7/dist-packages/httplib2-0.9-py2.7.egg/httplib2/__init__.py", line 80, in _ssl_wrap_socket
cert_reqs=cert_reqs, ca_certs=ca_certs)
File "/usr/lib/python2.7/ssl.py", line 886, in wrap_socket
ciphers=ciphers)
File "/usr/lib/python2.7/ssl.py", line 496, in __init__
self._context.load_verify_locations(ca_certs)
IOError: [Errno 13] Permission denied
On the other hand, running with sudo works perfectly
pankgeorg#snf-25181:~/tomotech/gmailer$ sudo python mailer.py
Message Id: 14ad0aea05e*****
To be completely honest, in order to authenicate using --noauth_local_webserver, I run the command with sudo, authenticated and chown the gmail.storage to myself again.
Also, I installed using easy_install because pip install was giving me the following error:
pankgeorg#snf-25181:~/tomotech/gmailer$ sudo pip install --upgrade google_api_python_client
Cleaning up...
Exception:
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pip/basecommand.py", line 122, in main
status = self.run(options, args)
File "/usr/local/lib/python2.7/dist-packages/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/lib/python2.7/dist-packages/pip/req.py", line 1096, in prepare_files
req_to_install, self.upgrade)
File "/usr/local/lib/python2.7/dist-packages/pip/index.py", line 194, in find_requirement
page = self._get_page(main_index_url, req)
File "/usr/local/lib/python2.7/dist-packages/pip/index.py", line 568, in _get_page
session=self.session,
File "/usr/local/lib/python2.7/dist-packages/pip/index.py", line 670, in get_page
resp = session.get(url, headers={"Accept": "text/html"})
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 395, in get
return self.request('GET', url, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip/download.py", line 237, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 383, in request
resp = self.send(prep, **send_kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 506, in send
history = [resp for resp in gen] if allow_redirects else []
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 168, in resolve_redirects
allow_redirects=False,
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/sessions.py", line 486, in send
r = adapter.send(request, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/adapters.py", line 330, in send
timeout=timeout
File "/usr/local/lib/python2.7/dist- packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 480, in urlopen
body=body, headers=headers)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/connectionpool.py", line 285, in _make_request
conn.request(method, url, **httplib_request_kw)
File "/usr/lib/python2.7/httplib.py", line 1001, in request
self._send_request(method, url, body, headers)
File "/usr/lib/python2.7/httplib.py", line 1035, in _send_request
self.endheaders(body)
File "/usr/lib/python2.7/httplib.py", line 997, in endheaders
self._send_output(message_body)
File "/usr/lib/python2.7/httplib.py", line 850, in _send_output
self.send(msg)
File "/usr/lib/python2.7/httplib.py", line 826, in send
self.sock.sendall(data)
File "/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/contrib/pyopenssl.py", line 323, in sendall
return self.connection.sendall(data)
File "/usr/lib/python2.7/dist-packages/OpenSSL/SSL.py", line 969, in sendall
raise TypeError("buf must be a byte string")
TypeError: buf must be a byte string
Storing debug log for failure in /root/.pip/pip.logrom oath2client import tool
It is my understanding that the root of the problem is the same in both cases.
I also have to note that my laptop (on which I can authenticate normally, on webbrowser, instead of --noauth_local_webserver) it works just fine, even though the installation is done the same way (the problem with pip appears there too).
Thanks in advance and sorry for the long post!
Tutorials I used:
parse arg
code for sending mails
application body is pretty much the quickstart for gmail api.
The httplib2 installer sets incorrect permissions for its httplib2/cacerts.txt file. One solution is to simply make its files readable by anyone by running
chmod o+r -R /usr/local/lib/python2.7/dist-packages/httplib2-0.9-py2.7.egg
However, it may be better to uninstall the version installed by pip, and use your operating system's package manager instead, which probably has the correct permissions for all files. On Debian, this could be accomplished with
pip uninstall httplib2
apt-get install python-httplib2

Categories