3

All I want to do is run a Python script that requires Python 2.7 & Requests on my Ubuntu 10.04 EC2 box. I installed Python 2.7, no problem. "python" by itself still points to python 2.6, which is very annoying, b/c I'm not sure how ubuntu will freak if I change the symlink /usr/bin/python to point to 2.7.

I followed the (carefully buried) install instructions for pip (at http://www.pip-installer.org/en/latest/index.html, and which are WAY too hard to find if they aren't the ABSOLUTE FIRST command on the "install pip" page)

So, the real problem here is that pip install requests completes successfully, but only installs for python 2.6, not 2.7. The pip usage instructions say nothing about how to install a package for a specific version of python.

How do I do this?

I just want to run my python script that requires 2.7 + requests.

4

3 回答 3

2

First install pip for your 2.7 distribution using easy_install (easy_install should definitely be included with your 2.7 distribution):

easy_install-2.7 -U pip

Then install what you need:

pip-2.7 install requests

Then you can run code with python2.7 instead of python.

于 2012-09-22T00:13:35.190 回答
0

Yeah it would be a bad idea to change the link pointing to which python version. Instead, can you change the shebang to say #!/usr/bin/env python2.7 instead of #!/usr/bin/env python ?

于 2012-09-21T20:40:42.797 回答
0

Though python2.7 /path/to/pip install requests might work; you should install pip for python2.7 separately instead.

If you don't use virtualenv then invoke pip as pip-2.7 (the command is available if you install pip for python2.7).

Follow installation instructions which is the first item in the table of contents. Substitute python with python2.7 in the instructions.

于 2012-09-22T02:23:35.667 回答