我想制作两个程序。我希望打印当前居住城市的天气,并且希望另一个人从在线帐户获取数据并将其返回。对于这些脚本,我导入yweather模块和请求模块。当我在shell中导入它们时没有问题,但是当我运行脚本时,它会显示“ImportError:No module named yweather”。我究竟做错了什么?为什么python模块在shell而不是在脚本中工作?
壳牌:
>>> import requests
>>>
脚本:
Traceback (most recent call last):
File "/Users/tim/Desktop/login.py", line 1, in <module>
import requests
ImportError: No module named requests
这也恰好为yweather模块
谢谢
您确定在这两种情况下使用的是相同的解释器吗? – deceze
您确定在运行脚本和提示时使用相同的Python版本吗? – trojek
向我们展示脚本的第一行。 – sphere