How to install virtualenv for Python 2.7?
Asked Answered
A

2

-1

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?

Archdeacon answered 15/12, 2023 at 0:57 Comment(0)
A
-1

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
Archdeacon answered 16/12, 2023 at 20:26 Comment(0)
A
-1

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
Archdeacon answered 15/12, 2023 at 1:14 Comment(0)
A
-1

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
Archdeacon answered 16/12, 2023 at 20:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.