简体   繁体   中英

Python: pip installing requests for older version: 2.7

I'm trying to interface with an API using a python program that only works in 2.7 and not in 3.4 which is also installed on my machine. However, one of my program's dependencies is the requests module. I have requests available in my 3.4 environment, but in 2.7 import requests results in:

import error: no such module named requests

Many Stack Overflow Q&A's have reccomended installing requests for 2.7 using: pip2.7 install requests , but apparently I don't have pip2.7 because that results in:

'pip2.7' is not recognized as an internal or external command

Question : How can I get pip2.7 instead of my default pip? Is it a seperate version of pip or do I just need to tell my current version I'm trying to install for version 2.7 not 2.4?

Note: The suggested solution to use easy_install-2.7 -U pip to install pip2.7 doesn't run on my Windows7 maching, the command propmt prints : easy_instal-2.7 is not recognized as an internal or external command

By default 3.4 won't create the plain pip command but it can be enabled with an option which is presumably what has been done in your case. Since there are other names for the Python 3 pip you can safely overwrite it by installing the 2.7 pip on top of it with easy_install .

Since this is Windows, your Python binaries are kept in isolated directories so you should just ensure that the 2.7 directory is first in the path variable. Look in the <python root 2.7>\\Scripts directory to see if you have an easy_install already. If not you need to install setuptools.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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