The below piece of code seems to fails for some people while the second one seems to works.
I would like to know why and which would be the best option to choose in order to minimize potential import failures?
from PIL import Image # Fails for some ?!
import Image
“
import Image” works because PIL makes use of the site-specific import hooks to add its install directory into the import path.The only situation I can think of where “
import Image” works but “from PIL import Image” doesn’t is if the install directory for PIL is outside of the import path but a.pthfile exists which points to/some/install/path/PIL.