Can not import name from X in python

2019-08-05 13:28发布

问题:

i want use Temp-mail lib to create a user. i installed it by pip install. when i want to call the class , it caused an error:

import email
File "C:\Users\11\Desktop\email.py", line 4, in <module>

from tempmail import TempMail
ImportError: cannot import name TempMail

the code is :

import requests
from tempmail import TempMail

tm = TempMail(login='denis', domain='@gnail.pw')
print tm.get_mailbox()  # list of emails in denis@gnail.pw

I'm sure there is a class TempMail in tempmail.py.

I have read about circular dependency but i do not figure out what the problem is.

edit:

totally , i want to use this site (temp-mail.ru/en) or something like this to generate email address , open it and confirm my registration from others website by click on the link, everything should be done in python and this process again and again when the new email arrived . what library do you suggest ? temp-mail ?

last edit i added some lib and the error has been changed /

http://uupload.ir/files/48vt_untitled.jpg

http://uupload.ir/files/dfig_untitled2.jpg

I used another class mail (pythons guerrilla mail) and this error is appeared about the class name.

回答1:

There are 2 modules that install a package called tempmail make sure you install only one of those.

  1. temp-mail
  2. tempMail

You can install temp-mail: (you will need this)

pip install temp-mail

You can install tempMail:

pip install tempMail

or

pip install tempmail

NOTE:

If you installed the second one try to remove it first:

pip uninstall tempMail
pip install temp-mail

if it is not working try this:

pip uninstall tempmail
pip install temp-mail


标签: python class