Search code examples
pythoncgismtplib

Error on importing smtplib only while starting python repl from cgi-bin directory


I'm able to import smtplib from any other directory except /opt/apache-dba/cgi-bin, it's failing with below error:

cd /opt/apache-dba/cgi-bin 
python 
>>> import smtplib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python2.7/smtplib.py", line 46, in <module>
    import email.utils
  File "email.py", line 3, in <module>
    from email.mime.multipart import MIMEMultipart
ImportError: No module named mime.multipart

But from any other directory:

$ python
Python 2.7.9 (default, Dec 21 2014, 11:02:59) [GCC] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import smtplib
>>>

I'm not sure what causing this behavior from cgi-bin directory. Can someone please help me to find the root cause? Thank you!


Solution

  • Issues is resolved, there is a email.py file under cgi-bin which is causing the issue, I've renamed the file to other name and it's working now.