I'm having this really weird error where I'm getting import errors in a Python shell launched from a home directory of an AWS EMR whereas the same packages are getting imported fine when I cd into another directory and launch the Python shell there.
The EMR has Python 2.7 installed. Please let me know what additional information I can provide. This issue is driving me crazy!
$ python
Python 2.7.16 (default, Mar 18 2019, 18:38:44)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> 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 2, in <module>
from email.mime.multipart import MIMEMultipart
ImportError: No module named mime.multipart
>>> os.path.realpath('./')
'/home/abc123'
>>>
$ mkdir temp
$ cd temp
[temp]$ python
Python 2.7.16 (default, Mar 18 2019, 18:38:44)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-28)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import smtplib
>>> os.path.realpath('./')
'/home/abc12/temp'
email.pyin the first (home) directory? Or a folder namedemail? If yes, then this can influence the import behaviour, due to python's lookup mechanics (app root takes precedence over other imports).email.py. Thank you! Do you want to change your comment into an answer so that I can accept it?