Skip to content
Advertisement

“Most likely due to circular import” in Python

JavaScript

Does anyone know why this piece of code returns this error when run and how to fix it?

JavaScript

When I run this code in normal IDLE it seems to work but it doesn’t work in Visual Studio Code.

Advertisement

Answer

It seems like the program file you have created is named threading.py, and you are importing a module also called threading. This causes a circular import because your file is shadowing the built-in module.

Please rename your program (e.g., threading_example.py).

Advertisement