cannot import name 'mydb' from partially initialized module 'connection' in Python

前端 未结 7 1536
南笙
南笙 2021-02-19 03:15

Python 3.8 error

ImportError: cannot import name \'mydb\' from partially initialized module \'connection\' 
(most likely due to a circular import) (C:\\U
sers\         


        
7条回答
  •  眼角桃花
    2021-02-19 03:49

    The error says that it is "most likely due to a circular import". Check to make sure that in the files you are importing you are not importing the file you showed. If you are that makes a circle of importing. for example my file is file.py and I am importing file2.py: import file > import file2 > import file > import file2 > import file... Make sure that is not happening. I had the same problem as you and this fixed it.

提交回复
热议问题