skip to Main Content

I tried the method suggested here for installing virtualenv. However, it gives a confusing error on Ubuntu 16:

% /usr/bin/python2.7 -m pip install virtualenv
Collecting virtualenv
  Using cached https://files.pythonhosted.org/packages/94/d7/adb787076e65dc99ef057e0118e25becf80dd05233ef4c86f07aa35f6492/virtualenv-20.25.0.tar.gz
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
    IOError: [Errno 2] No such file or directory: '/tmp/pip-build-toC2d7/virtualenv/setup.py'
    
    ----------------------------------------
Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-toC2d7/virtualenv/

I already have some virtualenv installed; I tried removing it as suggested here but that also doesn’t work:

% pip uninstall virtualenv
Cannot uninstall requirement virtualenv, not installed

How can I install virtualenv for Python 2.7?

2

Answers


  1. Chosen as BEST ANSWER

    The following seems to work on Ubuntu 16:

    apt-get install python-virtualenv
    

    pip is often trouble.

    Update

    This answer is not ideal. On Ubuntu 20, it gives me:

    # apt-get install python-virtualenv
    Reading package lists... Done
    Building dependency tree       
    Reading state information... Done
    Package python-virtualenv is not available, but is referred to by another package.
    This may mean that the package is missing, has been obsoleted, or
    is only available from another source
    
    E: Package 'python-virtualenv' has no installation candidate
    

  2. There is no need to install virtualenv. It is just a script. Download the Python 2.7 version as follows:

    git clone https://github.com/pypa/virtualenv.git virtualenv
    (cd virtualenv ; git checkout -b 13.1.2 13.1.2)
    

    (Later versions might work, but they rely on newer pips that spew warnings critiquing Python 2.7).

    Then you can create an environment env using the following command:

    /usr/bin/python2.7 virtualenv/virtualenv.py env
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search