1

我正在尝试在虚拟环境中通过 pip 安装旧版本的 Python:

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/ $ 

为什么会失败?

为什么 2.6 版不在 PyPI 中?

4

2 回答 2

1

Python 不是 python 包,因此不能由pip. 使用您的系统包管理器或从http://python.org安装您需要的 python 版本。你在 PyPI 上看到的显然不是真正的 python 包。

由于它在 PyPI 上链接,但不可安装,您可以将其归档为错误 :-)

于 2014-01-23T22:30:49.620 回答
1

可能不可能做你想做的事,因为在创建虚拟环境期间使用了特定的 python 版本。

如果您运行virtualenv --help(或者mkvirtualenv --help如果您正在使用 virtualenvwrapper),它会说明有关-p选项的以下内容:

-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)

检查此答案以获取更多信息:Use different Python version with virtualenv

于 2014-01-21T15:32:27.987 回答