python中requests已安装却仍报No module named requests错的原因

调用pip list可见已经成功安装了:

requests            2.21.0 

但是在运行时仍报错:

userdeMacBook-Pro:xiaohui user$ python test_web.py
Traceback (most recent call last):
  File "test_web.py", line 4, in <module>
    import requests
ImportError: No module named requests

可能是因为在本地安装了多个版本的python导致的,安装了python2和python3版本,运行时显示声明使用的是2版本即可:

python2 test_web.py

猜你喜欢

转载自www.cnblogs.com/wanghui-garcia/p/10412495.html
今日推荐