On MacOS (Mojave, same on High Sierra) with Python 3, after installing and using pyenv for some time, seemingly all operations that use a network connection return a UnicodeDecodeError.
So far I've tried using various versions of Python 3 (3.6.Xs, 3.7 tried), system provided python, uninstalling pyenv and reinstalling Python3 with brew, setting locale in ~/.bashrc, ~/.bash_profile, ~/.profile to en_US.UTF-8, running commands with prefixed PYTHONIOENCODING=utf-8 or LC_CTYPE=en_US.UTF-8.
The issue still presents when used with different Python 3 distributions (tried Anaconda, brew).
Returning to MacOs's python 2 fixed similar issue with python2 stack.
Examples (all issues present with different python3 distributions):
Using pip3 (pyenv 3.7)
pip3 install requests
Collecting requests
Exception:
Traceback (most recent call last):
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_internal/basecommand.py", line 228, in main
status = self.run(options, args)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 291, in run
resolver.resolve(requirement_set)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_internal/resolve.py", line 103, in resolve
self._resolve_one(requirement_set, req)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_internal/resolve.py", line 257, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_internal/resolve.py", line 210, in _get_abstract_dist_for
self.require_hashes
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_internal/operations/prepare.py", line 245, in prepare_linked_requirement
req.populate_link(finder, upgrade_allowed, require_hashes)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_internal/req/req_install.py", line 307, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_internal/index.py", line 484, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_internal/index.py", line 442, in find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_internal/index.py", line 587, in _get_pages
page = self._get_page(location)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_internal/index.py", line 705, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_internal/index.py", line 814, in get_page
"Cache-Control": "max-age=600",
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_vendor/requests/sessions.py", line 521, in get
return self.request('GET', url, **kwargs)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_internal/download.py", line 397, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_vendor/requests/sessions.py", line 494, in request
prep = self.prepare_request(req)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_vendor/requests/sessions.py", line 437, in prepare_request
hooks=merge_hooks(request.hooks, self.hooks),
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_vendor/requests/models.py", line 309, in prepare
self.prepare_auth(auth, url)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_vendor/requests/models.py", line 540, in prepare_auth
r = auth(self)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_internal/download.py", line 161, in __call__
netrc_auth = get_netrc_auth(req.url)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/site-packages/pip/_vendor/requests/utils.py", line 195, in get_netrc_auth
_netrc = netrc(netrc_path).authenticators(host)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/netrc.py", line 30, in __init__
self._parse(file, fp, default_netrc)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/netrc.py", line 39, in _parse
toplevel = tt = lexer.get_token()
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/shlex.py", line 105, in get_token
raw = self.read_token()
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/shlex.py", line 136, in read_token
nextchar = self.instream.read(1)
File "/Users/nikolaj/.pyenv/versions/3.7.1/lib/python3.7/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc5 in position 104: invalid continuation byte
Decoding responses to standard requests (on Anaconda)
Python 3.7.1 (default, Dec 14 2018, 13:28:58)
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> requests.get("http://www.google.pl")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/anaconda3/lib/python3.7/site-packages/requests/api.py", line 75, in get
return request('get', url, params=params, **kwargs)
File "/anaconda3/lib/python3.7/site-packages/requests/api.py", line 60, in request
return session.request(method=method, url=url, **kwargs)
File "/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 519, in request
prep = self.prepare_request(req)
File "/anaconda3/lib/python3.7/site-packages/requests/sessions.py", line 449, in prepare_request
auth = get_netrc_auth(request.url)
File "/anaconda3/lib/python3.7/site-packages/requests/utils.py", line 203, in get_netrc_auth
_netrc = netrc(netrc_path).authenticators(host)
File "/anaconda3/lib/python3.7/netrc.py", line 30, in __init__
self._parse(file, fp, default_netrc)
File "/anaconda3/lib/python3.7/netrc.py", line 39, in _parse
toplevel = tt = lexer.get_token()
File "/anaconda3/lib/python3.7/shlex.py", line 105, in get_token
raw = self.read_token()
File "/anaconda3/lib/python3.7/shlex.py", line 136, in read_token
nextchar = self.instream.read(1)
File "/anaconda3/lib/python3.7/codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xc5 in position 104: invalid continuation byte
My locale configuration
locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
You need to fix your ~/.netrc file to contain UTF-8-clean data. Currently it does not.
See the .netrc file documentation on what the file should contain.
The problem doesn't arise on Python 2, because there the file is not opened as Unicode text (Python 2 mostly operates in a binary data world).
Related
I am using anaconda Powershell Prompt in Win10. UnicodeDecodeError was reported when installing package with pip (version: 21.2.4). I found this error would reported with the kernel Python 3.6.7 and Python 3.9.7.Both the installation and the upgrade failed and reported the same error. I've tried the following command.
pip install simplejson
pip install simplejson --upgrade
The package can be anything and report the same bug.
Same error was reported using the Windows CMD. I tried the following command using Windows CMD.
py -m pip install simplejson
py -m pip install --upgrade pip
Here is the error report I got.
ERROR: Exception:
Traceback (most recent call last):
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\cli\base_command.py", line 173, in _main
status = self.run(options, args)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\cli\req_command.py", line 203, in wrapper
return func(self, options, args)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\commands\install.py", line 315, in run
requirement_set = resolver.resolve(
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\resolver.py", line 94, in resolve
result = self._result = resolver.resolve(
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 472, in resolve
state = resolution.resolve(requirements, max_rounds=max_rounds)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 341, in resolve
self._add_to_criteria(self.state.criteria, r, parent=None)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\resolvelib\resolvers.py", line 172, in _add_to_criteria
if not criterion.candidates:
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\resolvelib\structs.py", line 151, in __bool__
return bool(self._sequence)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 140, in __bool__
return any(self)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 128, in <genexpr>
return (c for c in iterator if id(c) not in self._incompatible_ids)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\found_candidates.py", line 29, in _iter_built
for version, func in infos:
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\resolution\resolvelib\factory.py", line 272, in iter_index_candidate_infos
result = self._finder.find_best_candidate(
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\index\package_finder.py", line 851, in find_best_candidate
candidates = self.find_all_candidates(project_name)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\index\package_finder.py", line 798, in find_all_candidates
page_candidates = list(page_candidates_it)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\index\sources.py", line 134, in page_candidates
yield from self._candidates_from_page(self._link)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\index\package_finder.py", line 758, in process_project_url
html_page = self._link_collector.fetch_page(project_url)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\index\collector.py", line 490, in fetch_page
return _get_html_page(location, session=self.session)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\index\collector.py", line 400, in _get_html_page
resp = _get_html_response(url, session=session)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\index\collector.py", line 115, in _get_html_response
resp = session.get(
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\requests\sessions.py", line 555, in get
return self.request('GET', url, **kwargs)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\network\session.py", line 454, in request
return super().request(method, url, *args, **kwargs)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\requests\sessions.py", line 528, in request
prep = self.prepare_request(req)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\requests\sessions.py", line 456, in prepare_request
p.prepare(
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\requests\models.py", line 320, in prepare
self.prepare_auth(auth, url)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\requests\models.py", line 556, in prepare_auth
r = auth(self)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\network\auth.py", line 208, in __call__
url, username, password = self._get_url_and_credentials(req.url)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\network\auth.py", line 180, in _get_url_and_credentials
username, password = self._get_new_credentials(original_url)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_internal\network\auth.py", line 145, in _get_new_credentials
netrc_auth = get_netrc_auth(original_url)
File "E:\Program Files\Anaconda3\lib\site-packages\pip\_vendor\requests\utils.py", line 216, in get_netrc_auth
_netrc = netrc(netrc_path).authenticators(host)
File "E:\Program Files\Anaconda3\lib\netrc.py", line 30, in __init__
self._parse(file, fp, default_netrc)
File "E:\Program Files\Anaconda3\lib\netrc.py", line 39, in _parse
toplevel = tt = lexer.get_token()
File "E:\Program Files\Anaconda3\lib\shlex.py", line 109, in get_token
raw = self.read_token()
File "E:\Program Files\Anaconda3\lib\shlex.py", line 140, in read_token
nextchar = self.instream.read(1)
UnicodeDecodeError: 'gbk' codec can't decode byte 0xff in position 0: illegal multibyte sequence
I have reinstalled the pip, Anaconda, and the python interpreter. It still failed. I think it has nothing to do with the pip. Something went wrong with the input stream. The default decode format is "GBK". I tried to change decode format to "utf-8" with the following command. It failed again with the same error.
chcp 65001
Thanks the suggestion from #Mobfi, I tried other similar commands, which return the same error notification.
chcp 437
chcp 850
Thanks the suggestion from #BoarGules, I start python with utf-8 decoder and tried to install/upgrade package with pip.
py -X utf8
I started the python console in powershell.
import pip
pip.main(['install', 'simplejson'])
Besides the similar traceback, I got another new traceback:
*same as aforementioned traceback*
File "E:\Program Files\Anaconda3\lib\codecs.py", line 322, in decode
(result, consumed) = self._buffer_decode(data, self.errors, final)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Anybody can help? Any potential solution, clues or similar experiences is welcomed.
Just moved to a new work computer and I seem to be getting the following error when I try to use pip. Wondering what the issue could be, python 3.7.2 on Windows 10.
Is it that my work password has characters that aren't allowed?
Strange because my older computer didn't have this issue.
Exception:
Traceback (most recent call last):
File "C:\Program Files\Python37\lib\site-packages\pip\_internal\cli\base_command.py", line 143, in main
status = self.run(options, args)
File "C:\Program Files\Python37\lib\site-packages\pip\_internal\commands\install.py", line 318, in run
resolver.resolve(requirement_set)
File "C:\Program Files\Python37\lib\site-packages\pip\_internal\resolve.py", line 102, in resolve
self._resolve_one(requirement_set, req)
File "C:\Program Files\Python37\lib\site-packages\pip\_internal\resolve.py", line 256, in _resolve_one
abstract_dist = self._get_abstract_dist_for(req_to_install)
File "C:\Program Files\Python37\lib\site-packages\pip\_internal\resolve.py", line 199, in _get_abstract_dist_for
skip_reason = self._check_skip_installed(req)
File "C:\Program Files\Python37\lib\site-packages\pip\_internal\resolve.py", line 170, in _check_skip_installed
self.finder.find_requirement(req_to_install, upgrade=True)
File "C:\Program Files\Python37\lib\site-packages\pip\_internal\index.py", line 572, in find_requirement
all_candidates = self.find_all_candidates(req.name)
File "C:\Program Files\Python37\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:\Program Files\Python37\lib\site-packages\pip\_internal\index.py", line 675, in _get_pages
page = self._get_page(location)
File "C:\Program Files\Python37\lib\site-packages\pip\_internal\index.py", line 793, in _get_page
return _get_html_page(link, session=self.session)
File "C:\Program Files\Python37\lib\site-packages\pip\_internal\index.py", line 144, in _get_html_page
"Cache-Control": "max-age=0",
File "C:\Program Files\Python37\lib\site-packages\pip\_vendor\requests\sessions.py", line 525, in get
return self.request('GET', url, **kwargs)
File "C:\Program Files\Python37\lib\site-packages\pip\_internal\download.py", line 396, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "C:\Program Files\Python37\lib\site-packages\pip\_vendor\requests\sessions.py", line 512, in request
resp = self.send(prep, **send_kwargs)
File "C:\Program Files\Python37\lib\site-packages\pip\_vendor\requests\sessions.py", line 622, in send
r = adapter.send(request, **kwargs)
File "C:\Program Files\Python37\lib\site-packages\pip\_vendor\requests\adapters.py", line 410, in send
conn = self.get_connection(request.url, proxies)
File "C:\Program Files\Python37\lib\site-packages\pip\_vendor\requests\adapters.py", line 308, in get_connection
proxy_manager = self.proxy_manager_for(proxy)
File "C:\Program Files\Python37\lib\site-packages\pip\_vendor\requests\adapters.py", line 191, in proxy_manager_for
proxy_headers = self.proxy_headers(proxy)
File "C:\Program Files\Python37\lib\site-packages\pip\_vendor\requests\adapters.py", line 389, in proxy_headers
password)
File "C:\Program Files\Python37\lib\site-packages\pip\_vendor\requests\auth.py", line 63, in _basic_auth_str
password = password.encode('latin1')
UnicodeEncodeError: 'latin-1' codec can't encode character '\u201d' in position 0: ordinal not in range(256)
Oops I think I resolved it minutes later. The instructions for the environmental variable for the proxy server password included a "" that wasn't supposed to actually be in the environmental variable text.
i'm using python 2.7 on a windows 10.
iv'e tried to install openpyxl using "pip install openpyxl"
and iv'e got an trace of errors, ending in "UnicodeDecodeError: 'ascii' codec can't decode byte".
I searched this site for solutions, and i tried to upgrade pip, as suggested in one of them.
When i typed "pip install --upgrade pip" i got the same error (i pasted the error trace below).
C:\Users\Gal>pip install --upgrade pip
Exception:
Traceback (most recent call last):
File "c:\python27\lib\site-packages\pip\basecommand.py", line 215, in main
status = self.run(options, args)
File "c:\python27\lib\site-packages\pip\commands\install.py", line 299, in
run
requirement_set.prepare_files(finder)
File "c:\python27\lib\site-packages\pip\req\req_set.py", line 370, in
prepare_files
ignore_dependencies=self.ignore_dependencies))
File "c:\python27\lib\site-packages\pip\req\req_set.py", line 458, in
_prepare_file
req_to_install, finder)
File "c:\python27\lib\site-packages\pip\req\req_set.py", line 407, in
_check_skip_installed
finder.find_requirement(req_to_install, self.upgrade)
File "c:\python27\lib\site-packages\pip\index.py", line 442, in
find_requirement
all_candidates = self.find_all_candidates(req.name)
File "c:\python27\lib\site-packages\pip\index.py", line 400, in
find_all_candidates
for page in self._get_pages(url_locations, project_name):
File "c:\python27\lib\site-packages\pip\index.py", line 545, in _get_pages
page = self._get_page(location)
File "c:\python27\lib\site-packages\pip\index.py", line 648, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "c:\python27\lib\site-packages\pip\index.py", line 757, in get_page
"Cache-Control": "max-age=600",
File "c:\python27\lib\site-packages\pip\_vendor\requests\sessions.py",
line 487, in get
return self.request('GET', url, **kwargs)
File "c:\python27\lib\site-packages\pip\download.py", line 378, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "c:\python27\lib\site-packages\pip\_vendor\requests\sessions.py",
line 475, in request
resp = self.send(prep, **send_kwargs)
File "c:\python27\lib\site-packages\pip\_vendor\requests\sessions.py",
line 617, in send
r.content
File "c:\python27\lib\site-packages\pip\_vendor\requests\models.py", line
741, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or
bytes()
File "c:\python27\lib\site-packages\pip\_vendor\requests\models.py", line
664, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "c:\python27\lib\site-
packages\pip\_vendor\requests\packages\urllib3\response.py", line 353, in
stream
data = self.read(amt=amt, decode_content=decode_content)
File "c:\python27\lib\site-
packages\pip\_vendor\requests\packages\urllib3\response.py", line 310, in
read
data = self._fp.read(amt)
File "c:\python27\lib\site-
packages\pip\_vendor\cachecontrol\filewrapper.py", line 54, in read
self.__callback(self.__buf.getvalue())
File "c:\python27\lib\site-
packages\pip\_vendor\cachecontrol\controller.py", line 297, in
cache_response
self.serializer.dumps(request, response, body=body),
File "c:\python27\lib\site-packages\pip\download.py", line 281, in set
return super(SafeFileCache, self).set(*args, **kwargs)
File "c:\python27\lib\site-
packages\pip\_vendor\cachecontrol\caches\file_cache.py", line 99, in set
with self.lock_class(name) as lock:
File "c:\python27\lib\site-
packages\pip\_vendor\lockfile\mkdirlockfile.py", line 19, in __init__
LockBase.__init__(self, path, threaded, timeout)
File "c:\python27\lib\site-packages\pip\_vendor\lockfile\__init__.py",
line 242, in __init__
hash(self.path)))
File "c:\python27\lib\ntpath.py", line 85, in join
result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xee in position 0:
ordinal not in range(128)
How can i solve this problem?
The answer above mine (the answer of Gal Avineri) was almost correct.
You should go to the ntpath file and change the line.
result_path = result_path + p_path
to the line,
result_path = result_path + p_path.decode('latin1')
I found the problem.
I saw that the last error came from ntpath, trying to decode a byte using ascii.
That meant that either result_path or p_path were string that were'nt encoded in ascii.
when i printed their types, it showed that result_path was unicode and p_path was a string. when i printed p_path, i recognized it was encoded in latin1.
So i replaced the line:
result_path = result_path + p_path
to the line:
result_path = result_path + decode(p_path,'latin1')
and that solved it :D
Above answers gave me the right clue but neither solution worked for me. Turns out I had the issue due to an 'å' in my username in windows.
I solved it by changing the line to:
result_path = result_path + p_path.encode('utf-8')
I'm trying to install the flake8 module for Python (in order to use the SublimeLinter-flake8 package to Sublime Text 3) but get an error message on install (below). What am I doing wrong here?
C:\Windows\system32>python -m pip install flake8
Collecting flake8
Exception:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\pip\basecommand.py", line 223, in main
status = self.run(options, args)
File "C:\Python27\lib\site-packages\pip\commands\install.py", line 280, in run
requirement_set.prepare_files(finder)
File "C:\Python27\lib\site-packages\pip\req\req_set.py", line 317, in prepare_files
functools.partial(self._prepare_file, finder))
File "C:\Python27\lib\site-packages\pip\req\req_set.py", line 304, in _walk_req_to_install
more_reqs = handler(req_to_install)
File "C:\Python27\lib\site-packages\pip\req\req_set.py", line 439, in _prepare_file
req_to_install.populate_link(finder, self.upgrade)
File "C:\Python27\lib\site-packages\pip\req\req_install.py", line 244, in populate_link
self.link = finder.find_requirement(self, upgrade)
File "C:\Python27\lib\site-packages\pip\index.py", line 486, in find_requirement
all_versions = self._find_all_versions(req.name)
File "C:\Python27\lib\site-packages\pip\index.py", line 404, in _find_all_versions
index_locations = self._get_index_urls_locations(project_name)
File "C:\Python27\lib\site-packages\pip\index.py", line 378, in _get_index_urls_locations
page = self._get_page(main_index_url)
File "C:\Python27\lib\site-packages\pip\index.py", line 810, in _get_page
return HTMLPage.get_page(link, session=self.session)
File "C:\Python27\lib\site-packages\pip\index.py", line 920, in get_page
"Cache-Control": "max-age=600",
File "C:\Python27\lib\site-packages\pip\_vendor\requests\sessions.py", line 477, in get
return self.request('GET', url, **kwargs)
File "C:\Python27\lib\site-packages\pip\download.py", line 373, in request
return super(PipSession, self).request(method, url, *args, **kwargs)
File "C:\Python27\lib\site-packages\pip\_vendor\requests\sessions.py", line 465, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\pip\_vendor\requests\sessions.py", line 605, in send
r.content
File "C:\Python27\lib\site-packages\pip\_vendor\requests\models.py", line 750, in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or bytes()
File "C:\Python27\lib\site-packages\pip\_vendor\requests\models.py", line 673, in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File "C:\Python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\response.py", line 307, in stream
data = self.read(amt=amt, decode_content=decode_content)
File "C:\Python27\lib\site-packages\pip\_vendor\requests\packages\urllib3\response.py", line 243, in read
data = self._fp.read(amt)
File "C:\Python27\lib\site-packages\pip\_vendor\cachecontrol\filewrapper.py", line 54, in read
self.__callback(self.__buf.getvalue())
File "C:\Python27\lib\site-packages\pip\_vendor\cachecontrol\controller.py", line 244, in cache_response
self.serializer.dumps(request, response, body=body),
File "C:\Python27\lib\site-packages\pip\download.py", line 276, in set
return super(SafeFileCache, self).set(*args, **kwargs)
File "C:\Python27\lib\site-packages\pip\_vendor\cachecontrol\caches\file_cache.py", line 99, in set
with self.lock_class(name) as lock:
File "C:\Python27\lib\site-packages\pip\_vendor\lockfile\mkdirlockfile.py", line 18, in __init__
LockBase.__init__(self, path, threaded, timeout)
File "C:\Python27\lib\site-packages\pip\_vendor\lockfile\__init__.py", line 189, in __init__
hash(self.path)))
File "C:\Python27\lib\ntpath.py", line 85, in join
result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe4 in position 9: ordinal not in range(128)
After startlingly generous help from Padraic, we eventually figured out that the problem was my computer name, which was Fredrik-Bärbar (notice the ä, i.e. 0xe4 in code page 850, there in the 10th place, or 9th place using Python's 0-based indexing).
(This error is related to that in Pip Error when installing, another question solved by Padraic.)
Description
There is no error when clone by http, the error only meet when clone by https.
Env
Install Mercurial by mercurial-1.9.1+20110801-py2.6-macosx10.6.mpkg from http://mercurial.berkwood.com/binaries/Mercurial-1.9.1-py2.6-macosx10.6.zip
site-packages location: /Library/Python/2.6/site-packages
Command:
hg clone https://code.google.com/p/cooliris-toolkit/
Error Info
hg clone https://code.google.com/p/cooliris-toolkit/
** unknown exception encountered, please report by visiting
** http://mercurial.selenic.com/wiki/BugTracker
** Python 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) [GCC 4.2.1 (Apple Inc. build 5646)]
** Mercurial Distributed SCM (version 1.9.1+20110801)
** Extensions loaded:
Traceback (most recent call last):
File "/usr/local/bin/hg", line 38, in
mercurial.dispatch.run()
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 27, in run
sys.exit(dispatch(request(sys.argv[1:])))
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 64, in dispatch
return _runcatch(req)
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 87, in _runcatch
return _dispatch(req)
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 679, in _dispatch
cmdpats, cmdoptions)
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 454, in runcommand
ret = _runcommand(ui, options, cmd, d)
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 733, in _runcommand
return checkargs()
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 687, in checkargs
return cmdfunc()
File "/Library/Python/2.6/site-packages/mercurial/dispatch.py", line 676, in
d = lambda: util.checksignature(func)(ui, *args, **cmdoptions)
File "/Library/Python/2.6/site-packages/mercurial/util.py", line 385, in check
return func(*args, **kwargs)
File "/Library/Python/2.6/site-packages/mercurial/commands.py", line 1041, in clone
branch=opts.get('branch'))
File "/Library/Python/2.6/site-packages/mercurial/hg.py", line 217, in clone
srcrepo = repository(remoteui(ui, peeropts), source)
File "/Library/Python/2.6/site-packages/mercurial/hg.py", line 93, in repository
repo = _peerlookup(path).instance(ui, path, create)
File "/Library/Python/2.6/site-packages/mercurial/httprepo.py", line 231, in instance
inst._fetchcaps()
File "/Library/Python/2.6/site-packages/mercurial/httprepo.py", line 56, in _fetchcaps
self.caps = set(self._call('capabilities').split())
File "/Library/Python/2.6/site-packages/mercurial/httprepo.py", line 164, in _call
fp = self._callstream(cmd, **args)
File "/Library/Python/2.6/site-packages/mercurial/httprepo.py", line 114, in _callstream
resp = self.urlopener.open(req)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 383, in open
response = self._open(req, data)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 401, in _open
'_open', req)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/urllib2.py", line 361, in _call_chain
result = func(*args)
File "/Library/Python/2.6/site-packages/mercurial/url.py", line 352, in https_open
return self.do_open(self._makeconnection, req)
File "/Library/Python/2.6/site-packages/mercurial/keepalive.py", line 256, in do_open
self._start_transaction(h, req)
File "/Library/Python/2.6/site-packages/mercurial/url.py", line 342, in _start_transaction
return keepalive.KeepAliveHandler._start_transaction(self, h, req)
File "/Library/Python/2.6/site-packages/mercurial/keepalive.py", line 354, in _start_transaction
h.endheaders()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 868, in endheaders
self._send_output()
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/httplib.py", line 740, in _send_output
self.send(msg)
File "/Library/Python/2.6/site-packages/mercurial/url.py", line 129, in _sendfile
orgsend(self, data)
File "/Library/Python/2.6/site-packages/mercurial/keepalive.py", line 537, in safesend
self.connect()
File "/Library/Python/2.6/site-packages/mercurial/url.py", line 331, in connect
sslutil.validator(self.ui, host)(self.sock)
File "/Library/Python/2.6/site-packages/mercurial/sslutil.py", line 97, in __call__
msg = _verifycert(sock.getpeercert(), host)
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/ssl.py", line 157, in getpeercert
return self._sslobj.peer_certificate(binary_form)
AttributeError: 'NoneType' object has no attribute 'peer_certificate'
Question
How can I resolve the error ? Is there any conflict in python libraries ?
After I installed Mercurial (version 1.9.3), I encountered the same problem with Sailing, when I hg clone https://code.google.com/p/vim/
And my solution is:
hg clone http://code.google.com/p/vim/
I guess Mercurial 1.9.3
sslutil.py has bug in line 105:
peercert = sock.getpeercert(True)