1. 程式人生 > >No module named 'tornado.ioloop'; 'tornado' is not a package

No module named 'tornado.ioloop'; 'tornado' is not a package

問題背景

最近要用到python tornado框架,結果一開始執行就報錯

py tornado.py

Traceback (most recent call last):
  File "tornado.py", line 2, in <module>
    import tornado.ioloop
  File "D:\workspace\python\python-com\tornado.py", line 2, in <module>
    import tornado.ioloop
ModuleNotFoundError: No module named 'tornado.ioloop'; 'tornado' is not a package

解決方案

修改tornado.py的檔名為其他的,這個是特殊保留的檔名,改完即可執行。