question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Python SDK circular import error

See original GitHub issue

I am trying to make a connection to the azure queue in Python but I am getting a circular import error.

Here’s my code: `from azure.storage.queue import (QueueClient)

connection_str = “”,

q_name = “test2” queue_client = QueueClient.from_connection_string(connection_str, q_name) queue_client.create_queue()`

Error I am getting: from azure.storage.queue import (QueueClient) ImportError: cannot import name 'QueueClient' from partially initialized module 'azure.storage.queue' (most likely due to a circular import) (/home/deepak/azure-env/lib/python3.8/site-packages/azure/storage/queue/__init__.py)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
deepak6422commented, Feb 14, 2022

hey @jalauzon-msft I figured out the issue. It was due to the file name which was queue.py. I think python causes this circular import error for any modules if their file name matches with the modules package file name.

0reactions
jalauzon-msftcommented, Feb 14, 2022

Hi @deepak6422, thanks for following up on this. It looks like this was indeed the cause as I was able to reproduce this on our end by naming the file queue.py. Interestingly this is not actually conflicting with our module since it’s called azure.storage.queue but instead with one of our dependencies, six (used by urllib). They have a module named queue which is causing this error. Unfortunately, there is not a lot we can do about that right now so just using a different file name is probably the best solution.

Thanks again for helping to find this. We can now recommend others against that file name if we see this issue in the future.

Read more comments on GitHub >

github_iconTop Results From Across the Web

class - Resolve circular import error in python - Stack Overflow
Class B won't be imported until you instantiate class A , by which time the module already has been imported fully by module...
Read more >
Python Circular Import Problem and Solutions
Generally, the Python Circular Import problem occurs when you accidentally name your working file the same as the module name and those modules...
Read more >
How to Solve Circular Import Error in Python - GyanBlog
Understand Circular Import. When you do simple import XYZ , it will work fine. By the time the code runs, all the modules...
Read more >
Avoiding Circular Imports in Python | by André Menck - Medium
We can trivially fix this particular circular import by changing our imports to import from the module where the object is actually defined....
Read more >
Python Circular Imports Module: Solving Circular Import Problem
Circular importing is a conceptual error that is formed due to circular dependency created with the import statement in our Python program.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found