我对此很陌生,请原谅我的无知,我正努力追赶并理解那里的所有信息。
Traceback (most recent call last):
File "weather.py", line 1, in <module>
from weather import Weather, Unit
File "/home/kumyl/Documents/Projects/Weather-api-test/weather.py", line 1, in <module>
from weather import Weather, Unit
ImportError: cannot import name Weather
这是我在做python weather.py或python3 weather.py时得到的错误。不知道为什么会这样。我在线查看,发现我需要更新pip,我已经这样做了:pip --version给了我
pip 19.0.2 from /usr/local/lib/python3.6/dist-packages/pip (python 3.6)
我认为这是最新的?我真的不知道这个问题。一些解决方案说要创建一个运行python的虚拟环境?不太确定这是什么,所以任何帮助将不胜感激。谢谢。
python将首先尝试从您的脚本导入,因为它具有相同的名称'weather.py'。您应该将文件的名称更改为其他名称,它应该可以使用。