简体   繁体   English

使用正确的python版本安装pip

[英]Installing pip with correct python version

I am on shared hosting and I need to install pip with the correct python version, 2.7. 我在共享主机上,我需要使用正确的python版本2.7安装pip。 To install pip, I did: 要安装pip,我做到了:

$ easy_install pip

However, after it was installed I get the following: 但是,安装后,我得到以下信息:

[dave@web1 lib]$ pip --version
pip 1.0.2 from /home/premiere/dave/financials/lib/pip-1.0.2-py2.7.egg (python 2.4)

How would I re-install pip to work on the python2.7 version, which is also installed on the machine? 我如何重新安装pip以在同时安装在机器上的python2.7版本上工作?

[premiered@web1 ~]$ python --version
Python 2.6.6

Which is strange, since it is installing to python2.4. 这很奇怪,因为它正在安装到python2.4。

You may want to create a virtualenv using -p /path/to/python-2.7.binary param, and then activate it. 您可能需要使用-p /path/to/python-2.7.binary参数创建virtualenv,然后将其激活。 Then all stuff you installed using pip would be correctly into your virtualenv. 然后,您使用pip安装的所有内容都将正确插入您的virtualenv中。

If multiple versions of python are installed on the system, then you should invoke the version you want when installing. 如果系统上安装了多个版本的python,则应在安装时调用所需的版本。 ie

$ python27 easy_install pip

This creates a pip file in your path that contains the specified version of python in the hashBang line. 这会在您的路径中创建一个pip文件,该文件在hashBang行中包含指定版本的python。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM