Pillow: How to install Pillow on OpenShift?

Created on 25 Jan 2014  ·  13Comments  ·  Source: python-pillow/Pillow

Could anyone give any pointers on how to install on OpenShift (Python 2.7 application).

Usually, I just add to requirements in setup.py eg:

install_requires=['bottle','pymongo','Pillow'],

code example: https://github.com/oshihirii/Python2.7MongoBottle/blob/master/setup.py

I did this and try to import from Python shell and get error:

>>> from PIL import Image
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named PIL

Most helpful comment

@AndreaCimminoArriaga - thanks for suggestion, for reference, I was able to install with these steps:

  1. ssh in
  2. source ~/python/virtenv/bin/activate
  3. pip install --log $OPENSHIFT_DATA_DIR/inst.log https://github.com/python-pillow/Pillow/archive/master.zip

All 13 comments

That should work, no idea why it didn't (other than I don't see Pillow in your code example's install_requires)

Thanks for confirmation, yes the code example was just to demonstrate how it was set up. The code I am using does actually define Pillow, but no dice at this stage.

"No dice" ?

“No dice” means “no success” or similar:
https://en.wiktionary.org/wiki/no_dice#English

I know what "no dice" means. I don't know the details of your failure, which would be particularly helpful in this context. IOW "No dice" leaves it open, whereas a traceback or some other detailed information might help us help you.

I have tried to install Pillow via a setup.py file using:

install_requires=['bottle','pymongo','Pillow'],

When I try and import Pillow from the shell I get this error:

>>> from PIL import Image
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: No module named PIL

Where would I look to find further information that could help troubleshoot the issue?

Maybe the problem is that openshift downloads the last version of Pillow, but you are running python 2.7 and (I'm not sure) the Pillow version is not compatible with 2.7. I have an app running with Python 3.3 and Pillow, I just follow the same steps you have and it works.
My setup.py is:
install_requires=['bottle','numpy','Pillow']
and my import is:
from PIL import *
as you can see is just the same, the unique difference between our project is the python version.
Hope this will be useful for you, if you want write me and i send you the my project folder so you can see it better.
Regards

@AndreaCimminoArriaga - thanks for suggestion, for reference, I was able to install with these steps:

  1. ssh in
  2. source ~/python/virtenv/bin/activate
  3. pip install --log $OPENSHIFT_DATA_DIR/inst.log https://github.com/python-pillow/Pillow/archive/master.zip

Why not install a release?

@AndreaCimminoArriaga All releases of Pillow should work with Python 2.7, see: http://pillow.readthedocs.org/en/latest/installation.html#platform-support

You are right, i think the problem of our discrepancies is because the PIL library itself, i will explain myself. Pillow is the ‘friendly’ PIL, but Pillow and Pil are not the same exactly. If you see the imports of @oshihirii and i at the beginning of this thread we were impor PIL not Pillow. And if you see the PIL page (http://www.pythonware.com/products/pil/) dosen't work in any python version (in fact dosen't work on the version 3.3). In the other hand now the library works for @oshihirii, if you see the way he install the library this time he install correctly Pillow. I know you maybe are thinking, "but in the setup.py i wrote 'Pillow' not 'PIL' so .... how it's possible that openshift installed PIL instead Pillow?"
i ask myself the same question and thought maybe was openshift that was installing the dependence Pillow as PIL. So i accessed to the console of my project and tried writting impor PIL, worked fine, and import Pillow, error. So the only answer that comes to me is that openshift searches the best matching dependency for Pillow and it finds PIL library (that dosen't work in any python version) that's why all this mess. If you install the Pillow version with pip and with the correct address of the Pillow library, that is what @oshihirii has done, you can install the Pillow, not the Pil library.
In any case to be sure of this hipotesis we have to make a project from 0 and see the oputput of openshift to be sure that the best matching for Pillow that finds is PIL. I have no time to do this, and i think the most important thing is that @oshihirii has resolved is problem. But if you do it, please tell me what you got.
I apologize if some english words or expresion are not correct, i have tried to explain myself in the better way i can. I hope this resolves all this mystery.
Regards.

@AndreaCimminoArriaga Both Pillow and PIL contain the PIL package, only the distribution name varies i.e. pip install PIL vs pip install Pillow. So when you are using Pillow, you will never import from Pillow; only PIL. This will likely never change.

Additionally, with PIL it is possible to do import Image. Pillow breaks this on purpose to avoid confusion and forces you to do from PIL import Image.

I understand you point, Pillow may contains the Pil package, but if openshift downloads PIL and not Pillow it will not work with any python versions. As i said before this is a theory, that openshift matches Pillow as PIL. I don't know 100% sure, but it's quite possible. In any case, if is not that i have no more ideas of the cause that have generated this thread.

Was this page helpful?
0 / 5 - 0 ratings