[英]Install older version of Python via pip
I am trying to install an older version of Python via pip in a virtual environment: 我试图通过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/ $
Why it's failing? 为什么会失败?
Why version 2.6 in not in PyPI? 为什么版本2.6不在PyPI中?
Probably is not possible to do what you want, because a particular python version is used during the creation of the virtual environment. 可能不可能做你想要的,因为在创建虚拟环境期间使用特定的python版本。
If you run virtualenv --help
(or maybe mkvirtualenv --help
if you are using virtualenvwrapper) it says the following about the -p option: 如果您运行virtualenv --help
(或者如果您使用的是virtualenvwrapper,则可能是mkvirtualenv --help
),它会对-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)
Check this answer for more info: Use different Python version with virtualenv 查看此答案以获取更多信息: 将不同的Python版本与virtualenv一起使用
Python is not a python package and therefore not installable by pip
. Python不是python包,因此不能通过pip
安装。 Use your systems package manager or install your needed python version from http://python.org . 使用您的系统包管理器或从http://python.org安装您需要的python版本。 What you can see on PyPI is obviously not a real python package. 你在PyPI上看到的显然不是一个真正的python包。
Since its linked on PyPI, but not installable you could file that as a bug :-) 由于它链接在PyPI上,但不能安装,你可以将其归档为bug :-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.