我正在努力在Amazon Web services的EC2实例上安装各种库。我尝试了各种安装方法,例如easy_install,pip和conda。安装conda后,我安装了requests
,并收到此成功消息
(base) El_Capitan:~/environment $ conda install requests
Collecting package metadata: done
Solving environment: done
# All requested packages already installed.
然后当我运行这个...
import requests
print("hello")
发生此错误
Traceback (most recent call last):
File "/home/ec2-user/environment/helloWorld.py", line 1, in <module>
import requests
ModuleNotFoundError: No module named 'requests'
通过pip安装,当我尝试安装软件包时出现此错误
(base) El_Capitan:~/environment $ sudo pip install requests
Requirement already satisfied: requests in /usr/local/lib/python2.7/site-packages
Requirement already satisfied: chardet<3.1.0,>=3.0.2 in /usr/local/lib/python2.7/site-packages (from requests)
Requirement already satisfied: certifi>=2017.4.17 in /usr/local/lib/python2.7/site-packages (from requests)
Requirement already satisfied: urllib3<1.25,>=1.21.1 in /usr/local/lib/python2.7/site-packages (from requests)
Requirement already satisfied: idna<2.8,>=2.5 in /usr/local/lib/python2.7/site-packages (from requests)
You are using pip version 9.0.3, however version 19.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
在REPL中运行时,终端可以正常运行并且没有问题,但是从脚本运行时,解释器无法识别模块。
(base) El_Capitan:~/environment $ python3
Python 3.7.1 (default, Dec 14 2018, 19:28:38)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import requests
>>> import numpy
有什么明显的原因使我想不到为什么我的实例无法识别请求的已安装版本? 预先感谢。