dnsimple / dnsimple-python

The DNSimple API client for Python.
https://developer.dnsimple.com/
MIT License
65 stars 42 forks source link

ImportError: cannot import name 'Client' from partially initialized module 'dnsimple' #438

Closed mecrayavcin closed 1 year ago

mecrayavcin commented 1 year ago
from dnsimple import Client
from dnsimple.struct import Contact, DomainRegistrationRequest

# Obtain your API token and Account ID
# https://support.dnsimple.com/articles/api-access-token/
client = Client(access_token="TOKEN")

account_id = 9999999

# Check for domain availability
response = client.registrar.check_domain(
      account_id,
      'google.com'
  )

print(response.data.available)

RESULT:

nv) C:\Users\SEO\Desktop\Python>C:/Users/SEO/anaconda3/envs/mainEnv/python.exe "c:/Users/SEO/Desktop/Python/Projects/Domain Backorder/Backorder/dnsimple.py" Traceback (most recent call last): File "c:\Users\SEO\Desktop\Python\Projects\Domain Backorder\Backorder\dnsimple.py", line 1, in from dnsimple import Client File "c:\Users\SEO\Desktop\Python\Projects\Domain Backorder\Backorder\dnsimple.py", line 1, in from dnsimple import Client ImportError: cannot import name 'Client' from partially initialized module 'dnsimple' (most likely due to a circular import) (c:\Users\SEO\Desktop\Python\Projects\Domain Backorder\Backorder\dnsimple.py)

At the first time when i tried it worked but after that try, i always get this error? How can i fix this? Thanks

DXTimer commented 1 year ago

The error message you're encountering, ImportError: cannot import name 'Client' from partially initialized module 'dnsimple', is indicative of a circular import issue. In Python, a circular import occurs when two or more modules depend on each other, directly or indirectly.

Here's a breakdown of what's going wrong in your code, based on the provided traceback:

Suggested action:

Change the dnsimple.py to something else to avoid namespace conflicts.

mecrayavcin commented 1 year ago

Thanks very much