aless80
aless80

Reputation: 3342

Problems installing Pillow/PIL in virtual environment without sudo

I have a program that I can run from terminal (no virtual environment) where I install packages with the --user option. Now I want to organize the program in a proper way in Python 2.7 using requirements.txt, setup.py, etc. To do this I created a virtual environment and I am installing all the necessary packages, so that I can do a "pip freeze > requirements.txt".

Unfortunately I cannot install PIL/Pillow. I used to get a problem with jpeg but I fixed that with "sudo apt-get install libjpeg-dev". Now with these:

pip install Pillow
pip install Pillow --allow-external Pillow --allow-unverified Pillow

I get a permission denied:

...
error: could not create '/home/kinkyboy/virtualenv/tantrix/lib/python2.7/site-packages/PIL': Permission denied

----------------------------------------
Cleaning up...
Command /home/kinkyboy/virtualenv/tantrix/bin/python -c "import setuptools, tokenize;__file__='/home/kinkyboy/virtualenv/tantrix/build/Pillow/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-S9cPV3-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/kinkyboy/virtualenv/tantrix/include/site/python2.7 failed with error code 1 in /home/kinkyboy/virtualenv/tantrix/build/Pillow
Storing debug log for failure in /home/kinkyboy/.pip/pip.log

If I use sudo it works and with --user it doesn't, but obviously these commands do not install in the virtual environment. Am I missing something?

Upvotes: 0

Views: 909

Answers (1)

aless80
aless80

Reputation: 3342

The solution was to chown the path to the virtual environment. Make sure both ~/.cache/pip and the path to the virtual environment are both owned by the user. In my case the second was not

sudo chown -R your_username:your_username path/to/virtuaelenv/

See @Vingtoft here: StackOverflow 19471972

Upvotes: 0

Related Questions