Error of Python virtualenv

Error of Python virtualenv

$ /usr/local/python-2.7/bin/virtualenv xp_mypy-2.7
New python executable in /scratch/xp_mypy-2.7/bin/python2.7
Also creating executable in /scratch/xp_mypy-2.7/bin/python
Installing setuptools, pip, wheel...
  Complete output from command /scratch/xp_mypy-2.7/bin/python2.7 - setuptools p                                                   ip wheel:
  Collecting setuptools
Exception:
Traceback (most recent call last):
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/commands/install.py", line 324, in run
    requirement_set.prepare_files(finder)
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/req/req_set.py", line 380, in prepare_files
    ignore_dependencies=self.ignore_dependencies))
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/req/req_set.py", line 554, in _prepare_file
    require_hashes
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/req/req_install.py", line 278, in populate_link
    self.link = finder.find_requirement(self, upgrade)
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/index.py", line 465, in find_requirement
    all_candidates = self.find_all_candidates(req.name)
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/index.py", line 423, in find_all_candidates
    for page in self._get_pages(url_locations, project_name):
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/index.py", line 568, in _get_pages
    page = self._get_page(location)
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/index.py", line 683, in _get_page
    return HTMLPage.get_page(link, session=self.session)
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/index.py", line 792, in get_page
    "Cache-Control": "max-age=600",
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/_vendor/requests/sessions.py", line 488, in get
    return self.request('GET', url, **kwargs)
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/download.py", line 386, in request
    return super(PipSession, self).request(method, url, *args, **kwargs)
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/_vendor/requests/sessions.py", line 475, in requ                                                   est
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/_vendor/requests/sessions.py", line 596, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/_vendor/cachecontrol/adapter.py", line 37, in se                                                   nd
    cached_response = self.controller.cached_request(request)
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/_vendor/cachecontrol/controller.py", line 111, i                                                   n cached_request
    resp = self.serializer.loads(request, cache_data)
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/_vendor/cachecontrol/serialize.py", line 114, in                                                    loads
    return getattr(self, "_loads_v{0}".format(ver))(request, data)
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/_vendor/cachecontrol/serialize.py", line 182, in                                                    _loads_v2
    cached["response"]["body"]
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv_support/pip                                                   -9.0.1-py2.py3-none-any.whl/pip/_vendor/cachecontrol/serialize.py", line 26, in                                                    _b64_decode_bytes
    return base64.b64decode(b.encode("ascii"))
UnicodeEncodeError: 'ascii' codec can't encode characters in position 0-39906: o                                                   rdinal not in range(128)
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "/usr/local/python-2.7/bin/virtualenv", line 3, in <module>
    virtualenv.main()
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv.py", line 7                                                   13, in main
    symlink=options.symlink)
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv.py", line 9                                                   45, in create_environment
    download=download,
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv.py", line 9                                                   01, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "/usr/local/python-2.7/lib/python2.7/site-packages/virtualenv.py", line 7                                                   97, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command /scratch/xp_mypy-2.7/bin/python2.7 - setuptools pip wheel faile                                                   d with error code 2

Solution

# let's assume your python installation is in this variable
my_python_path=/home/leo/tmp/test/

rm -Rf $HOME/.cache/pip
# not sure of the deletion of this one, but did it to be sure
rm -Rf $HOME/.pip
# remove of the pip and virtualenv
rm $my_python_path/bin/pip
rm $my_python_path/bin/virtualenv

# reinstall pip
$my_python_path/bin/python -m ensure pip
$my_python_path/bin/pip install virtualenv
$my_python_path/bin/virtualenv myenv