Pyenv-virtualenv: Creation of virtualenvs is broken on Python 2.x

Created on 19 Aug 2015  路  7Comments  路  Source: pyenv/pyenv-virtualenv

I'm able to use 2.7.10 (as installed by pyenv) just fine:

$ pyenv --version
pyenv 20150719
$ pyenv versions | grep 2.7.10
  2.7.10
$ pyenv global 2.7.10
$ pyenv which python
/Users/<username>/.pyenv/versions/2.7.10/bin/python
$ python --version
Python 2.7.10

I can create virtualenvs off of Python 3.x with no problems:

$ pyenv virtualenv 3.4.3 foo3
Ignoring indexes: https://pypi.python.org/simple
Requirement already satisfied (use --upgrade to upgrade): setuptools in /Users/<username>/.pyenv/versions/foo3/lib/python3.4/site-packages
Requirement already satisfied (use --upgrade to upgrade): pip in /Users/<username>/.pyenv/versions/foo3/lib/python3.4/site-packages
$ pyenv global 3.4.3
$ pyenv which python
/Users/<username>/.pyenv/versions/3.4.3/bin/python
$ python --version
Python 3.4.3

The same process fails for 2.x:

$ pyenv virtualenv 2.7.10 foo2
Requirement already satisfied (use --upgrade to upgrade): virtualenv in /usr/local/lib/python2.7/site-packages
pyenv: virtualenv: command not found

The `virtualenv' command exists in these Python versions:
  <...list of a few versions, all of which came from pyenv-virtualenv...>

Installing pip from https://bootstrap.pypa.io/get-pip.py...
pyenv: version `foo2' is not installed
error: failed to install pip via get-pip.py

What's odd is that I was able to install virtualenvs off of 2.x a few weeks ago.

Most helpful comment

Bumb!

Same thing happened in my laptop under Lubuntu 16.04 LTS.

When I run this command in terminal,
pyenv virtualenv 2.7.8 my-virtual-env-2.7.8

It caused an error as below.
Requirement already satisfied (use --upgrade to upgrade): virtualenv in ./.local/lib/python2.7/site-packages
pyenv: virtualenv: command not found
Installing pip from https://bootstrap.pypa.io/get-pip.py...
pyenv: version `2.7.8/envs/my-virtual-env-2.7.8' is not installed (set by PYENV_VERSION environment variable)
error: failed to install pip via get-pip.py

After I reviewed jackmaney's comments, I focused that there is a weird directory in my ~/.local.
I finally solved this by removing these directories.
rm -fr ~/.local/bin
rm -fr ~/.local/lib

Thank you, jackmaney!

June

All 7 comments

This issue doesn't seem to be universal. On a RHEL box at work, I can create virtualenvs on 2.x via pyenv virtualenv with no problems. On my laptop running OS X 10.9.5, I'm still running into the same issues as above...

FWIW, I've never had a problem with this on Ubuntu:

$ pyenv virtualenv 2.7.10 foo
New python executable in /home/vagrant/.pyenv/versions/foo/bin/python2.7
Also creating executable in /home/vagrant/.pyenv/versions/foo/bin/python
Installing setuptools, pip, wheel...done.
Ignoring indexes: https://pypi.python.org/simple
Requirement already satisfied (use --upgrade to upgrade): setuptools in /home/vagrant/.pyenv/versions/foo/lib/python2.7/site-packages
Requirement already satisfied (use --upgrade to upgrade): pip in /home/vagrant/.pyenv/versions/foo/lib/python2.7/site-packages

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04 LTS
Release:        14.04
Codename:       trusty

I think I fixed it...the shebang in the system's virtualenv and pip executables were pointing to the hard-coded location of Homebrew's Python 2.7 installation (which, for reasons I don't remember, had been uninstalled). So...after:

  • Wiping out Python, pyenv, and pyenv-virtualenv in Homebrew
  • Wiping virtualenv and pip in both /usr/local/bin and /Library/Python/2.7/site-packages
  • Reinstalling pyenv and pyenv-virtualenv, and
  • Manually reinstalling pip and virtualenv on the system Python

Everything seems to be fixed. Lesson learned: never do brew link python. Ever.

Bumb!

Same thing happened in my laptop under Lubuntu 16.04 LTS.

When I run this command in terminal,
pyenv virtualenv 2.7.8 my-virtual-env-2.7.8

It caused an error as below.
Requirement already satisfied (use --upgrade to upgrade): virtualenv in ./.local/lib/python2.7/site-packages
pyenv: virtualenv: command not found
Installing pip from https://bootstrap.pypa.io/get-pip.py...
pyenv: version `2.7.8/envs/my-virtual-env-2.7.8' is not installed (set by PYENV_VERSION environment variable)
error: failed to install pip via get-pip.py

After I reviewed jackmaney's comments, I focused that there is a weird directory in my ~/.local.
I finally solved this by removing these directories.
rm -fr ~/.local/bin
rm -fr ~/.local/lib

Thank you, jackmaney!

June

I guess removing whole lib is too much. This worked for me:

rm ~/.local/lib/python2.7/site-packages/virtualenv*

@qwertyjune thanks. the rm -fr ~/.local/bin solved the issue with Ubuntu

rm -r ~/.local/lib/python2.7/site-packages/virtualenv* worked for me.

Thanks Bartekbrak.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tjorriemorrie picture Tjorriemorrie  路  8Comments

tmoschou picture tmoschou  路  9Comments

dimaqq picture dimaqq  路  7Comments

draeath picture draeath  路  4Comments

oblitum picture oblitum  路  11Comments