Python 3.4.3 virtualenv error code 2

855 views Asked by At

Setup: Windows 7 Python: 3.4.3 VirtualEnv: 13.0.3 Pip: 7.0.3

I'm trying to setup a virtualenv on Window 7 but am getting the following error:

    C:\test>virtualenv venv

    Using base prefix 'C:\\Python34'
    New python executable in venv\Scripts\python.EXE
    Installing setuptools, pip, wheel...
      Complete output from command C:\test\venv\Scripts\python.EXE -c "import sys, p
    ip; sys...d\"] + sys.argv[1:]))" setuptools pip wheel:
      Ignoring indexes: https://pypi.python.org/simple
    Collecting setuptools
    Exception:
    Traceback (most recent call last):
      File "C:\Python34\lib\site-packages\virtualenv_support\pip-7.0.3-py2.py3-none-
    any.whl\pip\basecommand.py", line 223, in main
        status = self.run(options, args)
      File "C:\Python34\lib\site-packages\virtualenv_support\pip-7.0.3-py2.py3-none-
    any.whl\pip\commands\install.py", line 280, in run
        requirement_set.prepare_files(finder)
      File "C:\Python34\lib\site-packages\virtualenv_support\pip-7.0.3-py2.py3-none-
    any.whl\pip\req\req_set.py", line 317, in prepare_files
        functools.partial(self._prepare_file, finder))
      File "C:\Python34\lib\site-packages\virtualenv_support\pip-7.0.3-py2.py3-none-
    any.whl\pip\req\req_set.py", line 304, in _walk_req_to_install
        more_reqs = handler(req_to_install)
      File "C:\Python34\lib\site-packages\virtualenv_support\pip-7.0.3-py2.py3-none-
    any.whl\pip\req\req_set.py", line 439, in _prepare_file
        req_to_install.populate_link(finder, self.upgrade)
      File "C:\Python34\lib\site-packages\virtualenv_support\pip-7.0.3-py2.py3-none-
    any.whl\pip\req\req_install.py", line 244, in populate_link
        self.link = finder.find_requirement(self, upgrade)
      File "C:\Python34\lib\site-packages\virtualenv_support\pip-7.0.3-py2.py3-none-
    any.whl\pip\index.py", line 486, in find_requirement
        all_versions = self._find_all_versions(req.name)
      File "C:\Python34\lib\site-packages\virtualenv_support\pip-7.0.3-py2.py3-none-
    any.whl\pip\index.py", line 407, in _find_all_versions
        self.find_links, expand_dir=True)
      File "C:\Python34\lib\site-packages\virtualenv_support\pip-7.0.3-py2.py3-none-
    any.whl\pip\index.py", line 234, in _sort_locations
        sort_path(os.path.join(path, item))
      File "C:\Python34\lib\site-packages\virtualenv_support\pip-7.0.3-py2.py3-none-
    any.whl\pip\index.py", line 215, in sort_path
        if mimetypes.guess_type(url, strict=False)[0] == 'text/html':
      File "C:\Python34\Lib\mimetypes.py", line 287, in guess_type
        init()
      File "C:\Python34\Lib\mimetypes.py", line 348, in init
        db.read_windows_registry()
      File "C:\Python34\Lib\mimetypes.py", line 255, in read_windows_registry
        with _winreg.OpenKey(hkcr, subkeyname) as subkey:
    TypeError: OpenKey() argument 2 must be str without null characters or None, not
     str

    ----------------------------------------
    ...Installing setuptools, pip, wheel...done.
    Traceback (most recent call last):
      File "C:\Python34\lib\runpy.py", line 170, in _run_module_as_main
        "__main__", mod_spec)
      File "C:\Python34\lib\runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "C:\Python34\Scripts\virtualenv.exe\__main__.py", line 9, in <module>
      File "C:\Python34\lib\site-packages\virtualenv.py", line 832, in main
        symlink=options.symlink)
      File "C:\Python34\lib\site-packages\virtualenv.py", line 1004, in create_envir
    onment
        install_wheel(to_install, py_executable, search_dirs)
      File "C:\Python34\lib\site-packages\virtualenv.py", line 969, in install_wheel

        'PIP_NO_INDEX': '1'
      File "C:\Python34\lib\site-packages\virtualenv.py", line 910, in call_subproce
    ss
        % (cmd_desc, proc.returncode))
    OSError: Command C:\test\venv\Scripts\python.EXE -c "import sys, pip; sys...d\"]
     + sys.argv[1:]))" setuptools pip wheel failed with error code 2

    C:\test>

I've search far and wide but found no solution that solves my issue. Hoping someone can help.

1

There are 1 answers

0
Davs Howard On BEST ANSWER

It was a bug within the Python 3.4.3 installer that was supposedly fixed. I redownload and reinstalled Python but to no avail.

I managed to find the fix having followed a rabbit hole which just involved amending a mimetypes.py file

https://hg.python.org/cpython/rev/bf2016a1911f