我正在尝试通过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中?
答案 0 :(得分:1)
可能无法做到你想要的,因为在创建虚拟环境的过程中会使用特定的python版本。
如果您运行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)
查看此答案以获取更多信息:Use different Python version with virtualenv
答案 1 :(得分:1)
Python不是python包,因此pip
无法安装。使用您的系统包管理器或从http://python.org安装所需的python版本。 What you can see on PyPI显然不是真正的python包。
由于它在PyPI上链接但不可安装,你可以将其作为错误提交: - )