1

I am trying to install an older version of Python via pip in a virtual environment:

vic@vic ~/projects/ $ mkvirtualenv test
New python executable in test/bin/python
Installing setuptools............done.
Installing pip...............done.

[test] vic@vic ~/projects/ $ pip install python==2.6.6
Downloading/unpacking python==2.6.6
  Could not find a version that satisfies the requirement python==2.6.6 (from versions: 2.7.5, 3.3.2, 2.3, 2.4, 2.4, 2.4.1, 2.4.1, 3.3.2, 2.7.5, 2.7.5, 2.5, 2.5)
No distributions matching the version for python==2.6.6
Storing complete log in /home/vic/.pip/pip.log

1 [test] vic@vic ~/projects/ $ python                   
Python 2.7.5+ (default, Sep 19 2013, 13:48:49) 
[GCC 4.8.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> 

[test] vic@vic ~/projects/ $ pip install python==2.4  
Downloading/unpacking python==2.4
  Downloading Python-2.4.tgz (9.2MB): 9.2MB downloaded
  Running setup.py egg_info for package python

  Requested python==2.4, but installing version 2.7.5-
Installing collected packages: python
  Found existing installation: Python 2.7
    Not uninstalling Python at /usr/lib/python2.7/lib-dynload, outside environment /home/vic/projects/venv/test
  Running setup.py install for python
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]
       or: -c --help [cmd1 cmd2 ...]
       or: -c --help-commands
       or: -c cmd --help

    error: option --single-version-externally-managed not recognized
    Complete output from command /home/vic/projects/venv/test/bin/python -c "import setuptools;__file__='/home/vic/projects/venv/test/build/python/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-M2b0rc-record/install-record.txt --single-version-externally-managed --install-headers /home/vic/projects/venv/test/include/site/python2.7:
    usage: -c [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...]

   or: -c --help [cmd1 cmd2 ...]

   or: -c --help-commands

   or: -c cmd --help



error: option --single-version-externally-managed not recognized

----------------------------------------
  Can't roll back Python; was not uninstalled
Command /home/vic/projects/venv/test/bin/python -c "import setuptools;__file__='/home/vic/projects/venv/test/build/python/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-M2b0rc-record/install-record.txt --single-version-externally-managed --install-headers /home/vic/projects/venv/test/include/site/python2.7 failed with error code 1 in /home/vic/projects/venv/test/build/python
Storing complete log in /home/vic/.pip/pip.log

1 [test] vic@vic ~/projects/ $ 

Why it's failing?

Why version 2.6 in not in PyPI?

warvariuc
  • 57,116
  • 41
  • 173
  • 227
  • In order to use virtualenv with different python version, version has to be already installed, see [this answer](http://stackoverflow.com/a/11301911/2927973) – alko Nov 08 '13 at 12:33
  • Yes, I've already seen and upvoted that answer. But I've been told that it's possible to install another version of Python via pip. And I've found [`python`](https://pypi.python.org/pypi/Python) packages on PyPI. – warvariuc Nov 08 '13 at 13:04
  • sorry, no experience then. i use pyenv for this task – alko Nov 08 '13 at 15:41

2 Answers2

1

Probably is not possible to do what you want, because a particular python version is used during the creation of the virtual environment.

If you run virtualenv --help (or maybe mkvirtualenv --help if you are using virtualenvwrapper) it says the following about the -p option:

-p PYTHON_EXE, --python=PYTHON_EXE
                        The Python interpreter to use, e.g.,
                        --python=python2.5 will use the python2.5 interpreter
                        to create the new environment.  The default is the
                        interpreter that virtualenv was installed with
                        (/usr/bin/python)

Check this answer for more info: Use different Python version with virtualenv

Community
  • 1
  • 1
matiascelasco
  • 1,145
  • 2
  • 13
  • 18
  • First: the parameter -p suggests to me that a particular python version is binded to each virtual environment at the time of its creation and because of that is not possible to install another python version later using 'pip install' Second: sorry about the link! now is fixed. – matiascelasco Jan 23 '14 at 22:32
1

Python is not a python package and therefore not installable by pip. Use your systems package manager or install your needed python version from http://python.org. What you can see on PyPI is obviously not a real python package.

Since its linked on PyPI, but not installable you could file that as a bug :-)

knitti
  • 6,817
  • 31
  • 42
  • I did `pip install --download . python==2.5` which downloaded `Python-2.5.tgz` to the current directory. There is `setup.py` inside - looks like an installer. Why this installer could not compile Python and install it into the virtual environment? – warvariuc Jan 24 '14 at 02:42
  • It's great you tried, I didn't even know you'd get a download this way. In the .tgz is probably some README which could help further. I assume, that most dependencies on compiling python are *not* fetchable by pip, since they are no python libraries either – knitti Jan 24 '14 at 07:51