20

never had this issue until just recently, but when trying to create a new virtual environment (windows 7, python 2.7.13, virtualenv==15.1.0) it just hangs on "Installing setuptools, pip, wheel..." and doing a crtl^c gives you this:

PS C:\Users\John\Envs> virtualenv.exe rmapvenv
New python executable in C:\Users\John\Envs\test\Scripts\python.exe
Installing setuptools, pip, wheel...done.
Traceback (most recent call last):
  File "c:\python27\lib\runpy.py", line 162, in _run_module_as_main
    "__main__", fname, loader, pkg_name)
  File "c:\python27\lib\runpy.py", line 72, in _run_code
    exec code in run_globals
  File "C:\Python27\Scripts\virtualenv.exe\__main__.py", line 9, in <module>
  File "c:\python27\lib\site-packages\virtualenv.py", line 713, in main
    symlink=options.symlink)
  File "c:\python27\lib\site-packages\virtualenv.py", line 945, in create_environment
    download=download,
  File "c:\python27\lib\site-packages\virtualenv.py", line 901, in install_wheel
    call_subprocess(cmd, show_stdout=False, extra_env=env, stdin=SCRIPT)
  File "c:\python27\lib\site-packages\virtualenv.py", line 769, in call_subprocess
    line = stdout.readline()
KeyboardInterrupt

adding some print statements in virtualenv.py gives me this:

Running command C:\Users\John\Envs\test\Scripts\python.exe - setuptools pip wheel

Collecting setuptools

  Using cached setuptools-35.0.1-py2.py3-none-any.whl

Collecting pip

Collecting wheel

it seems to be hung up on wheel

John
  • 359
  • 1
  • 3
  • 9
  • 2
    As far as I can tell, this just suggests that the program is waiting on output from a command it has called. `call_subprocess` takes a command (as `cmd`) and executes it, and reads the stdout of that process. You can see here it's waiting on a full line to be written. Could you try running this inside a debugger and getting the value of `cmd`, which should indicate the subprocess that's really hanging. – Gareth Pulham Apr 25 '17 at 00:01
  • updated the original question with more details. – John Apr 25 '17 at 02:19
  • Hi John try to create the virtualenv giving to this the executable python path like this: `virtualenv --python=C:\Python27\python.exe env` I'm using windows 10 virtualenv 13, but I don't think this matter – Reidel Apr 25 '17 at 19:58
  • yields the same results – John Apr 25 '17 at 23:32
  • Possible duplicate of [setting up environment in virtaulenv using python3 stuck on setuptools, pip, wheel](https://stackoverflow.com/questions/45674311/setting-up-environment-in-virtaulenv-using-python3-stuck-on-setuptools-pip-whe) – Vineet Jain Nov 03 '17 at 06:43

6 Answers6

13

Use the -v switch to get Verbose output.

For me, it was a network connection. Specifically, the server I was trying to use virtualenv on was firewalled from the Internet and I needed to get out thru a proxy. Except, that virtualenv doesn't seem to honor the proxy settings in the environment and it has no commandline switch.

So use pip to pre-cache/pre-download the 3 needed packages:

sudo pip download setuptools pip wheel --proxy http://<yourproxyhere>

Then you can run virtualenv and it will use the cached packages that you just downloaded.

Pretzel
  • 8,141
  • 16
  • 59
  • 84
6

I was using pipenv to install a venv :

$ pipenv install
Creating a virtualenv for this project…
Pipfile: /home/seba/Sources/neogeo/grandlyon/photon-setup/Pipfile
Using /usr/bin/python3 (3.6.7) to create virtualenv…
⠦ Creating virtual environment...

Verbose mode didn't give me more information, --clear was useless but using ps auxf, I saw the python process was waiting for nothing:

 [...] S+   09:59   0:00  |   |       \_ /home/seba/Sources/[...]/venv/bin/python3 - setuptools pip wheel

It stalled installing setuptools.

Creating a virtualenv as usual confirmed me this:

$ virtualenv -vv --python=python3 venv
[...]
Running command /home/seba/Sources/n...tup/venv/bin/python3 - setuptools pip wheel
Looking in links: /usr/local/lib/python3.6/dist-packages/virtualenv_support
Collecting setuptools
[Waiting forever]

The fix was dropping pip cache:

$ rm -Rf ~/.cache/pip/ ~/.cache/pip-tools/
3

I ran into this as well and none of the answers above worked. Turned out to be a bad cache entry.

With $ virtualenv -vv venv I'd get output ending with:

Running command /Users/ghartmann/cod...test/venv/bin/python - setuptools pip wheel
Collecting setuptools
    Cache entry deserialization failed, entry ignored

It would block there and then when you interrupted you'd see the stack indicating it was blocked downloading the wheel package.

On macos the pip cache is here: ~/Library/Caches/pip.
Removing that directory fixed the issue, as it was able to reinitialize the cache.

Gabriel
  • 163
  • 6
2

Everything seemed to revolve around wheel not installing, so if someone can explain this, please do. this is what I did to get it to install. I ran:

virtualenv venv --no-wheel

then, activated my virtual environment and ran:

pip install --upgrade pip
pip install setuptools --no-use-wheel --upgrade
pip install wheel --no-cache

and as far as I can tell, everything works

tobych
  • 2,941
  • 29
  • 18
John
  • 359
  • 1
  • 3
  • 9
1

I was behind a corporate firewall using pipenv. Even though the Pipfile was pointing to our local package index (not PyPi), the pip that pipenv called was still trying to use PyPi and hanging at

/home/eric/.local/share/virtualenvs/venv/bin/python - setuptools pip wheel

The solution for me was to either set the index URL in pip.conf or use the PIP_INDEX_URL environment variable, for example:

PIP_INDEX_URL=http://my.corporate.index/simple pipenv lock
sourcedelica
  • 23,940
  • 7
  • 66
  • 74
0

I'm not sure if it will help but I had the exact same problem, albeit on linux debian (raspbian Jessie light to be precise) and python 3.6. Wheel hanged upon creating a virtualenv, and I got the same error messages as you after a ctrl-c (with python 3.6 and linux paths). I then had unnoticed internet connection problems, after solving these, wheel installed properly.

calocedrus
  • 2,430
  • 20
  • 25