MINGW-packages: Creation of a Python Virtualenv Fails

This is somewhat related to #2745, but the original issue posted is different, so I thought it would be worthwhile having an issue posted for virtualenv failing.

I would like to have Python virtualenv’s working in msys2. When trying to make a virtualenv:

$ virtualenv venv
Using base prefix 'C:/msys64/mingw64'
New python executable in C:/Users/DYEAW/Projects/test-venv/venv/Scripts/python3.exe
Also creating executable in C:/Users/DYEAW/Projects/test-venv/venv/Scripts/python.exe
Installing setuptools, pip, wheel...
  Complete output from command C:/Users/DYEAW/Proje.../Scripts/python3.exe - setuptools pip wheel:
  Traceback (most recent call last):
  File "<stdin>", line 3, in <module>
ModuleNotFoundError: No module named 'pkgutil'
----------------------------------------
...Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "C:\msys64\mingw64\bin\virtualenv-script.py", line 11, in <module>
    load_entry_point('virtualenv==16.0.0', 'console_scripts', 'virtualenv')()
  File "C:/msys64/mingw64/lib/python3.7/site-packages\virtualenv.py", line 712, in main
    symlink=options.symlink)
  File "C:/msys64/mingw64/lib/python3.7/site-packages\virtualenv.py", line 947, in create_environment
    download=download,
  File "C:/msys64/mingw64/lib/python3.7/site-packages\virtualenv.py", line 904, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "C:/msys64/mingw64/lib/python3.7/site-packages\virtualenv.py", line 796, in call_subprocess
    % (cmd_desc, proc.returncode))
OSError: Command C:/Users/DYEAW/Proje.../Scripts/python3.exe - setuptools pip wheel failed with error code 1

Or trying it the now recommended way:

$ python3 -m venv venv
Error: [WinError 2] The system cannot find the file specified

These are the installed Python 3 packages:

mingw-w64-x86_64-python3 3.7.2-1
mingw-w64-x86_64-python3-apipkg 1.5-2
mingw-w64-x86_64-python3-appdirs 1.4.3-3
mingw-w64-x86_64-python3-atomicwrites 1.3.0-1
mingw-w64-x86_64-python3-attrs 18.2.0-1
mingw-w64-x86_64-python3-beaker 1.10.0-2
mingw-w64-x86_64-python3-cachecontrol 0.12.5-1
mingw-w64-x86_64-python3-cairo 1.18.0-1
mingw-w64-x86_64-python3-certifi 2018.11.29-2
mingw-w64-x86_64-python3-chardet 3.0.4-2
mingw-w64-x86_64-python3-colorama 0.4.1-1
mingw-w64-x86_64-python3-distlib 0.2.8-1
mingw-w64-x86_64-python3-gobject 3.30.4-1
mingw-w64-x86_64-python3-html5lib 1.0.1-3
mingw-w64-x86_64-python3-idna 2.8-1
mingw-w64-x86_64-python3-iniconfig 1.0.0-2
mingw-w64-x86_64-python3-lockfile 0.12.2-1
mingw-w64-x86_64-python3-mako 1.0.7-3
mingw-w64-x86_64-python3-markupsafe 1.1.0-1
mingw-w64-x86_64-python3-more-itertools 5.0.0-1
mingw-w64-x86_64-python3-msgpack 0.6.1-1
mingw-w64-x86_64-python3-packaging 19.0-1
mingw-w64-x86_64-python3-pep517 0.5.0-1
mingw-w64-x86_64-python3-pip 19.0.1-1
mingw-w64-x86_64-python3-pluggy 0.8.1-1
mingw-w64-x86_64-python3-progress 1.4-3
mingw-w64-x86_64-python3-py 1.7.0-2
mingw-w64-x86_64-python3-pyparsing 2.3.1-1
mingw-w64-x86_64-python3-pytest 4.3.0-1
mingw-w64-x86_64-python3-pytoml 0.1.20-1
mingw-w64-x86_64-python3-requests 2.21.0-1
mingw-w64-x86_64-python3-retrying 1.3.3-1
mingw-w64-x86_64-python3-setuptools 40.8.0-1
mingw-w64-x86_64-python3-six 1.12.0-1
mingw-w64-x86_64-python3-urllib3 1.24.1-1
mingw-w64-x86_64-python3-virtualenv 16.0.0-1
mingw-w64-x86_64-python3-webencodings 0.5.1-3

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 4
  • Comments: 33 (18 by maintainers)

Commits related to this issue

Most upvoted comments

It looks like you might have renamed your python.exe executable to python3.exe? I got this same error after following install instructions that had me rename python.exe to be version specific. I renamed it back and python -m venv venv worked fine.

Why not use venv instead? It’s built in to python.

I can confirm the same errors as reported by @danyeaw using either methods.

However, I found out that:

  • With python3 -m venv --without-pip venv, the command exits without any errors, but the virtualenv is completely broken. Almost empty in fact. python.exe isn’t even present in the Scripts directory.
  • With python3 -m virtualenv --no-setuptools --no-wheel --no-pip venv, the command also exits without any errors. At first glance the virtualenv seems OK. Once activated, if python is launched, it complains it cannot find libpython3.7m.dll.

Don’t know if this helps anyone. I’m not sure what to make of it.

Just had this issue. It happened because nodeJS installed python2.7 and added it to the path, perhaps it has overriten the python3 path. Adding the python 3 instalation file to the path again and putting it before the python2 file in the path list solved my problem. Now when I run python on the comand line it actually runs python3. It changes when I switch the order in the path

Problem seems that python from venv not see modules from host python

@danyeaw @deanmsands3 @FlyingWombat this is more fixes - https://github.com/msys2/MINGW-packages/commit/d583e5a01308503abc9fb5605ee7fb91fcbe7ab9

I can’t do anything more here myself. Feel free to contribute more suolutions

Well seems need more changes for virtualenv. Feel free to do some investigation)