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.
[me@oldserver]$ cat /usr/lib/python2.4/site-packages/PIL.pth
PIL
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 .pth
file exists which points to /some/install/path/PIL
.
refering PIL Install
Step 1 : Install the build dependencies
sudo apt-get build-dep python-imaging
Step 2 : Symlink the libraries
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libfreetype.so /usr/lib/
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libjpeg.so /usr/lib/
sudo ln -s /usr/lib/`uname -i`-linux-gnu/libz.so /usr/lib/
Step 3 : Install
pip install PIL
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