LoginSignup
32
26

More than 5 years have passed since last update.

Pythonで module 'XXX' has no attribute 'XXX' が出た時の解決方法

Posted at

Pythonで module 'XXX' has no attribute 'XXX' が出た時の解決方法

プログラムを実行するとエラーが出た。

Traceback (most recent call last):
  File "xxx.py", line 1, in <module>
    import xxx
  File "/Users/tonosamart/xxx.py", line 4, in <module>
    def zzz(arg: xxx.yyy):
AttributeError: module 'yyy' has no attribute 'xxx'

なんかよくわかんないけど、import失敗してる感じ?

importの指定と同じファイル名のプログラムがあると、そっちを読みに行ってしまうのが原因><
他の言語と違い、ファイル名=クラス名にできないのめんどい

はまったのでメモ

32
26
5

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
32
26