Patterson Patterson - 1 year ago 95
Python Question

I cannot import a module and I don't know why Python: ImportError: Cannot import name X

I'm having the following error when I try to run a Flask app:

File "/home/patterson/Documentos/CPFL/cpfl/computer.py", line 12, in <module>
from cpfl.cpfl import sendmail
ImportError: cannot import name 'sendmail'


sendmail is a function I'm trying to import from the cpfl.py module which is a flask app.
cpfl.py:

...
app = Flask(__name__)
...


The structure of my project is as follows:

enter image description here

I have no idea why import does not work.
Could someone help-me?

Answer Source

Have you tried import cpfl and then when you call the method you use cpfl.sendmail?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download