0

I want to import the Pillow module. But I have to install it just into the folder of the script which is using it. I tried to set a search path and import it:

sWorkDir = os.path.dirname(os.path.realpath(__file__))
print (sWorkDir)
sys.path.append(sWorkDir+"\\PIL_LOC")
sys.path.append(sWorkDir+"\\PIL_LOC\PIL")
import Image

Unfortunately, I get a

from . import VERSION, PILLOW_VERSION, _plugins
ImportError: attempted relative import with no known parent package
dgrat
  • 2,214
  • 4
  • 24
  • 46

1 Answers1

0

Since I can't make a comment under your original post, I'll make it like an answer.

I've found this, try to see if it works for you!

$ sudo apt-get install python3-dev python3-setuptools

$ sudo apt-get install libtiff4-dev libjpeg8-dev zlib1g-dev \
    libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk

$ sudo apt-get install python3-pip

$ sudo pip3 install Pillow

$ sudo apt-get install imagemagick

$ sudo ln -s /usr/bin/display /usr/bin/xv

Then in the python3.4 interactive shell enter:

from PIL import Image

im = Image.open("someimage.jpg")
im.show()

Credits goes to: Using Pillow with Python 3

Backup
  • 66
  • 1
  • 8