LoginSignup
1
0

More than 3 years have passed since last update.

Pythonでパッケージをimportしたあと怒られる:'most likely due to a circular import'

Posted at

(原因)importしようとしているパッケージ名と同じファイル名でpythonスクリプトを作成している。

(対策)次を確認すること:import pyocr しているスクリプトのファイル名が pyocr.py になっていないか?
→ YESならファイル名をパッケージ名とは異なるものに変える(ocrtest.py等)。同じ名前だと循環参照になってしまう。

エラーの例

Traceback (most recent call last):
  File "pyocr.py", line 6, in <module>
    import pyocr
  File "pyocr.py", line 8, in <module>
    tools = pyocr.get_available_tools()
AttributeError: partially initialized module 'pyocr' has no attribute 'get_available_tools' (most likely due to a circular import)
1
0
0

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
1
0