Ошибка кодека ASCII при настройке virtualenv с помощью pyenv-virtualenv - PullRequest
0 голосов
/ 10 ноября 2019

Мне нужно использовать версию Python, отличную от установленной в системе. Чтобы сделать это, я использовал penv для установки нужной версии - 2.7.12, а затем отображается правильная версия:

pyenv which python
/root/.pyenv/versions/2.7.12/bin/python

Когда я пытаюсь создать новую виртуальную среду, используя следующую команду:

[root@localhost site-packages] pyenv virtualenv 2.7.12 nanovar

New python executable in /root/.pyenv/versions/2.7.12/envs/nanovar/bin/python2.7
Also creating executable in /root/.pyenv/versions/2.7.12/envs/nanovar/bin/python
Installing setuptools, pip, wheel...

  Complete output from command /root/.pyenv/version...anovar/bin/python2.7 - setuptools pip wheel:
  DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.
Created temporary directory: /tmp/pip-ephem-wheel-cache-gFPfrS
Created temporary directory: /tmp/pip-req-tracker-UI5fK2
Created requirements tracker '/tmp/pip-req-tracker-UI5fK2'
Created temporary directory: /tmp/pip-install-Ck6zPW
Looking in links: /root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support
Collecting setuptools
  1 location(s) to search for versions of setuptools:
  * https://pypi.org/simple/setuptools/
  Skipping link /root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support (from -f); not a file
  Getting page https://pypi.org/simple/setuptools/
  Looking up "https://pypi.org/simple/setuptools/" in the cache
  Request header has "max_age" as 0, cache bypassed
Cleaning up...
Removed build tracker '/tmp/pip-req-tracker-UI5fK2'
ERROR: Exception:
Traceback (most recent call last):
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_internal/cli/base_command.py", line 178, in main
    status = self.run(options, args)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_internal/commands/install.py", line 352, in run
    resolver.resolve(requirement_set)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_internal/resolve.py", line 131, in resolve
    self._resolve_one(requirement_set, req)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_internal/resolve.py", line 294, in _resolve_one
    abstract_dist = self._get_abstract_dist_for(req_to_install)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_internal/resolve.py", line 242, in _get_abstract_dist_for
    self.require_hashes
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_internal/operations/prepare.py", line 282, in prepare_linked_requirement
    req.populate_link(finder, upgrade_allowed, require_hashes)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_internal/req/req_install.py", line 198, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_internal/index.py", line 766, in find_requirement
    candidates = self.find_candidates(req.name, req.specifier)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_internal/index.py", line 752, in find_candidates
    self.find_all_candidates(project_name),
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_internal/index.py", line 716, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_internal/index.py", line 846, in _get_pages
    page = _get_html_page(location, session=self.session)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_internal/index.py", line 231, in _get_html_page
    resp = _get_html_response(url, session=session)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_internal/index.py", line 179, in _get_html_response
    "Cache-Control": "max-age=0",
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_vendor/requests/sessions.py", line 546, in get
    return self.request('GET', url, **kwargs)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_internal/download.py", line 439, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_vendor/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_vendor/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_vendor/cachecontrol/adapter.py", line 51, in send
    request.headers.update(self.controller.conditional_headers(request))
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_vendor/cachecontrol/controller.py", line 233, in conditional_headers
    resp = self.serializer.loads(request, self.cache.get(cache_url))
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_vendor/cachecontrol/serialize.py", line 97, in loads
    return getattr(self, "_loads_v{}".format(ver))(request, data)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_vendor/cachecontrol/serialize.py", line 161, in _loads_v2
    cached["response"]["body"] = _b64_decode_bytes(cached["response"]["body"])
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv_support/pip-19.1.1-py2.py3-none-any.whl/pip/_vendor/cachecontrol/serialize.py", line 13, in _b64_decode_bytes
    return base64.b64decode(b.encode("ascii"))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-57970: ordinal not in range(128)
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "/root/.pyenv/versions/2.7.12/bin/virtualenv", line 11, in <module>
    sys.exit(main())
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv.py", line 870, in main
    symlink=options.symlink,
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv.py", line 1173, in create_environment
    install_wheel(to_install, py_executable, search_dirs, download=download)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv.py", line 1019, in install_wheel
    _install_wheel_with_search_dir(download, project_names, py_executable, search_dirs)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv.py", line 1110, in _install_wheel_with_search_dir
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=script)
  File "/root/.pyenv/versions/2.7.12/lib/python2.7/site-packages/virtualenv.py", line 963, in call_subprocess
    raise OSError("Command {} failed with error code {}".format(cmd_desc, proc.returncode))
OSError: Command /root/.pyenv/version...anovar/bin/python2.7 - setuptools pip wheel failed with error code 2
Ignoring indexes: https://pypi.python.org/simple
Collecting setuptools
Collecting pip
Installing collected packages: setuptools, pip
Successfully installed pip-8.1.1 setuptools-20.10.1

Я не могу понять проблему кодека ascii, я попытался установить LC_CTYPE = "C.UTF-8", но безрезультатно. Что может быть не так? Является ли система установленным Python мешающим Python, который я установил с pyenv?

1 Ответ

0 голосов
/ 10 ноября 2019

Очистка кеша пипов помогла мне решить эту проблему.

cd $HOME/.cache 
rm -r pip
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...