I get the following error
Traceback (most recent call last):
File "myemail.py", line 1, in <module>
import smtplib
File "/usr/lib/python2.6/smtplib.py", line 46, in <module>
import email.utils
File "/home/nikhil/Desktop/bujji/email.py", line 2, in <module>
ImportError: No module named MIMEMultipart
when i run the code example
I tried to google out the error but nothing worked.
This is caused by the fact that the version of Python you're running your script with is not configured to search for modules where you've installed them. This happens when you use the wrong installation of pip to install packages.
You can manually go and check the PYTHONPATH variable contents to find the directories from where these built in modules are being imported. Running "python -v"from the command line tells you what is being imported and from where. This is useful if you want to know the location of built in modules.
In Python, you use the import keyword to make code in one module available in another. Imports in Python are important for structuring your code effectively. Using imports properly will make you more productive, allowing you to reuse code while keeping your projects maintainable.
You've stomped on the email
package in the stdlib by naming a script email.py
. Rename it.
Don't have enough reputation to comment on Ignacio Vazquez-Abrams's answer but make sure that not only do you remove email.py put also things like email.py~ and email.pyc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With