我安装了python 3.4.1,并且需要运行python 2脚本。我通过运行make install
安装了python 2.7.5。当我运行我的脚本时,它写道:
Traceback (most recent call last):
File "/root/roseltorg/run.py", line 2, in <module>
import requests
ImportError: No module named requests
然后我尝试安装请求模块但是:
pip install requests
Requirement already satisfied (use --upgrade to upgrade): requests in /usr/local/lib/python3.4/site-packages/requests-2.11.1-py3.4.egg
Cleaning up...
如何强制为python 2.7安装此模块?
答案 0 :(得分:1)
我更喜欢在这种情况下使用virtualenv。
virtualenv -p path_to_python2.7 .(current dir)
source bin/activate
pip install requests
答案 1 :(得分:1)
使用pip
安装到python 3.4,这意味着pip
指向pip3
。尝试这样做
pip2 install requests