Fail during installation of Pillow (Python module) in Linux - python

I'm trying to install Pillow (Python module) using pip, but it throws this error:
ValueError: jpeg is required unless explicitly disabled using --disable-jpeg, aborting
So as the error says, I tried:
pip install pillow --global-option="--disable-jpeg"
But it fails with:
error: option --disable-jpeg not recognized
Any hints how to deal with it?

There is a bug reported for Pillow here, which indicates that libjpeg and zlib are now required as of Pillow 3.0.0.
The installation instructions for Pillow on Linux give advice of how to install these packages. Note that not all of the following packages may be missing on your machine (comments suggest that only libjpeg8-dev is actually missing).
pip / PyPi (Pillow>3.4.2)
The latest releases of Pillow are available on PyPi as wheels — the new standard packaging mechanism for Python. These prebuilt packages include all neccessary binary dependencies to allow Pillow to run and should be used if you want to install Pillow using PyPi
To use wheels, you need to have a version of pip>=1.4. If you are using an earlier version (pip --version) upgrade pip using the following:
pip install --upgrade pip
Once pip is upgraded, pip install will use platform-specific wheel files by default if they are available. Use the following command to upgrade Pillow to the latest version available on PyPi:
pip install --upgrade pillow
Ubuntu 12.04 LTS or Raspian Wheezy 7.0
sudo apt-get install libtiff4-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.5-dev tk8.5-dev python-tk
Ubuntu 14.04
sudo apt-get install libtiff5-dev libjpeg8-dev zlib1g-dev libfreetype6-dev liblcms2-dev libwebp-dev tcl8.6-dev tk8.6-dev python-tk
Ubuntu 18.04
sudo apt install libjpeg8-dev zlib1g-dev
Fedora 20
The Fedora 20 equivalent of libjpeg8-dev is libjpeg-devel.
sudo yum install libtiff-devel libjpeg-devel libzip-devel freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel
Mac OS X (via Homebrew)
On Mac OS X with Homebrew this can be fixed using:
brew install libjpeg zlib
You may also need to force-link zlib using the following:
brew link zlib --force
Update April 2019: In Mojave the above will not work and you need to run the following as taken from this bug report on Pillow
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
Update July 2016: There is no longer a formula for zlib available in the main repository (Homebrew will prompt you to install lzlib which is a different library and will not solve this problem).
There is a formula available in the dupes repository. You can either tap this repository, and install as normal:
brew tap homebrew/dupes
brew install zlib
Or you can install zlib via xcode instead, as follows:
xcode-select --install
Thanks to phoenix, Panos Angelopoulou, nelsonvarela, benjaminz and Kal in the comments
After these are installed the pip installation of Pillow should work normally.

On Raspberry pi II, I had the same problem. After trying the following, I solved the problem. The solution is:
sudo apt-get update
sudo apt-get install libjpeg-dev

Thank you #mfitzp. In my case (CentOS) these libs are not available in the yum repo, but actually the solution was even easier. What I did:
sudo yum install python-devel
sudo yum install zlib-devel
sudo yum install libjpeg-turbo-devel
And now pillow's installation finishes successfully.

The quickest fix is upgrate the pip. Did worked for me:
pip install --upgrade pip

This worked for me to solve jpeg and zlib error :
C:\Windows\system32>pip3 install pillow --global-option="build_e
xt" --global-option="--disable-zlib" --global-option="--disable-jpeg"

This worked for me.
`sudo apt-get install libjpeg-dev`

brew install zlib
on OS X doesn't work anymore and instead prompts to install lzlib. Installing that doesn't help.
Instead you install XCode Command line tools and that should install zlib
xcode-select --install

I had the ValueError: zlib is required unless explicitly disabled using --disable-zlib but upgrading pip from 7.x to 8.y resolved the problem.
So I would try to update tools before anything else.
That can be done using:
pip install --upgrade pip

The alternative, if you don't want to install libjpeg:
CFLAGS="--disable-jpeg" pip install pillow
From https://pillow.readthedocs.io/en/3.0.0/installation.html#external-libraries

Working successfuly :
sudo apt install libjpeg8-dev zlib1g-dev

Anyone with Python 3.9 you can only install Pillow 8.0, Any version lower than that wouldn't work. For more check here.
So you can run it like this:
pip install Pillow==8.0.0
BTW this is tested on pip 21.0.1 (python 3.9) on MacOS Big Sur 11.2

Try
pip install pillow
If it doesn't work, try clearing the
cache by pip install --upgrade pip
Then again run
pip install pillow

On debian / ubuntu you only need:
libjpeg62-turbo-dev
So a simple sudo apt install libjpeg62-turbo-dev
and a pip install pillow

Related

Cannot install h5py

I'm trying to install h5py, but when I do pip install h5py or use python setup.py install from the source code, fatal error:
hdf5.h: No such file or directory.
Other posts mention to do pip install libhdf5-dev or pip install libhdf5-serial-dev to resolve this, but it says "no matching distribution found."
How can I install h5py? I am ssh'd into an Odyssey computer using the CentOS 6.5 version of the Linux. Also, I do not have sudo privileges. Thanks!
Your error is because you are missing the hdf5.h header, pip will not install the development headers, you need to install them using your package manager, on Centos it would be:
yum install hdf5-devel
If you look at the installation instrcutions:
Source installation on Linux and OS X
You need, via apt-get, yum or Homebrew:
Python 2.6, 2.7, 3.3, or 3.4 with development headers (python-dev or similar)
HDF5 1.8.4 or newer, shared library version with development headers (libhdf5-dev or similar)
NumPy 1.6.1 or later
This link helped:
https://github.com/Homebrew/legacy-homebrew/issues/23144
I installed LinuxHomeBrew and did:
brew tap homebrew/science
brew install hdf5
pip install h5py
I was able to install h5py!
sudo apt-get update
sudo apt-get install python-h5py
(Source)
Also, not pip install libhdf5-dev or pip install libhdf5-serial-dev, but apt install libhdf5-dev and apt install libhdf5-serial-dev.
Then, run pip install h5py
Running the below fixed my problem as I had an error related to xlocale.h
sudo ln -s /usr/include/locale.h /usr/include/xlocale.h

How can I install a specific version of pip via easy-install? - Mac OS Mavericks

I am constantly getting the
Cannot fetch index base URL https://pypi.python.org/simple/
whenever I try to pip install anything with the most recent pip version.
I read on some other questions that pip was having SSL related issues in its latest version and recommended to install pip 1.2.1.
How do I install a specific version of pip via easy_install for example?
You should be able to install pip with pip:
pip install --upgrade pip==1.2.1
Based on your context, you can uninstall as above and then run:
sudo easy_install pip==1.2.1
No more pesky SSL errors.
Uninstall any previous installation of pip. Considering you are using system wide installation,
sudo apt-get remove python-pip
and also,
pip uninstall pip
Now,
sudo apt-get install python-setuptools
sudo easy_install pip==<specific version>
sudo pip install virtualenv
It's preferred to use virtual environment though.

Install line 'pip install scipy' fails [duplicate]

It is possible to install NumPy with pip using pip install numpy.
Is there a similar possibility with SciPy? (Doing pip install scipy does not work.)
Update
The package SciPy is now available to be installed with pip!
Prerequisite:
sudo apt-get install build-essential gfortran libatlas-base-dev python-pip python-dev
sudo pip install --upgrade pip
Actual packages:
sudo pip install numpy
sudo pip install scipy
Optional packages:
sudo pip install matplotlib OR sudo apt-get install python-matplotlib
sudo pip install -U scikit-learn
sudo pip install pandas
src
An attempt to easy_install indicates a problem with their listing in the Python Package Index, which pip searches.
easy_install scipy
Searching for scipy
Reading http://pypi.python.org/simple/scipy/
Reading http://www.scipy.org
Reading http://sourceforge.net/project/showfiles.php?group_id=27747&package_id=19531
Reading http://new.scipy.org/Wiki/Download
All is not lost, however; pip can install from Subversion (SVN), Git, Mercurial, and Bazaar repositories. SciPy uses SVN:
pip install svn+http://svn.scipy.org/svn/scipy/trunk/#egg=scipy
Update (12-2012):
pip install git+https://github.com/scipy/scipy.git
Since NumPy is a dependency, it should be installed as well.
In Ubuntu 10.04 (Lucid), I could successfully pip install scipy (within a virtualenv) after installing some of its dependencies, in particular:
$ sudo apt-get install libamd2.2.0 libblas3gf libc6 libgcc1 libgfortran3 liblapack3gf libumfpack5.4.0 libstdc++6 build-essential gfortran libatlas-sse2-dev python-all-dev
To install scipy on windows follow these instructions:-
Step-1 : Press this link http://www.lfd.uci.edu/~gohlke/pythonlibs/#scipy to download a scipy .whl file (e.g. scipy-0.17.0-cp34-none-win_amd64.whl).
Step-2: Go to the directory where that download file is there from the command prompt (cd folder-name ).
Step-3: Run this command:
pip install scipy-0.17.0-cp27-none-win_amd64.whl
I tried all the above and nothing worked for me. This solved all my problems:
pip install -U numpy
pip install -U scipy
Note that the -U option to pip install requests that the package be upgraded. Without it, if the package is already installed pip will inform you of this and exit without doing anything.
If I first install BLAS, LAPACK and GCC Fortran as system packages (I'm using Arch Linux), I can get SciPy installed with:
pip install scipy
On Fedora, this works:
sudo yum install -y python-pip
sudo yum install -y lapack lapack-devel blas blas-devel
sudo yum install -y blas-static lapack-static
sudo pip install numpy
sudo pip install scipy
If you get any public key errors while downloading, add --nogpgcheck as parameter to yum, for example:
yum --nogpgcheck install blas-devel
On Fedora 23 onwards, use dnf instead of yum.
For the Arch Linux users:
pip install --user scipy prerequisites the following Arch packages to be installed:
gcc-fortran
blas
lapack
Addon for Ubuntu (Ubuntu 10.04 LTS (Lucid Lynx)):
The repository moved, but a
pip install -e git+http://github.com/scipy/scipy/#egg=scipy
failed for me... With the following steps, it finally worked out (as root in a virtual environment, where python3 is a link to Python 3.2.2):
install the Ubuntu dependencies (see elaichi), clone NumPy and SciPy:
git clone git://github.com/scipy/scipy.git scipy
git clone git://github.com/numpy/numpy.git numpy
Build NumPy (within the numpy folder):
python3 setup.py build --fcompiler=gnu95
Install SciPy (within the scipy folder):
python3 setup.py install
In my case, it wasn't working until I also installed the following package : libatlas-base-dev, gfortran
sudo apt-get install libatlas-base-dev gfortran
Then run pip install scipy
install python-3.4.4
scipy-0.15.1-win32-superpack-python3.4
apply the following commend doc
py -m pip install --upgrade pip
py -m pip install numpy
py -m pip install matplotlib
py -m pip install scipy
py -m pip install scikit-learn
The answer is yes, there is.
First you can easily install numpy use commands:
pip install numpy
Then you should install mkl, which is required by Scipy, and you can download it here
After download the file_name.whl you install it
C:\Users\****\Desktop\a> pip install mkl_service-1.1.2-cp35-cp35m-win32.whl
Processing c:\users\****\desktop\a\mkl_service-1.1.2-cp35-cp35m-win32.whl
Installing collected packages: mkl-service
Successfully installed mkl-service-1.1.2
Then at the same website you can download scipy-0.18.1-cp35-cp35m-win32.whl
Note:You should download the file_name.whl according to you python version, if you python version is 32bit python3.5 you should download this one, and the "win32" is about your python version, not your operating system version.
Then install file_name.whl like this:
C:\Users\****\Desktop\a>pip install scipy-0.18.1-cp35-cp35m-win32.whl
Processing c:\users\****\desktop\a\scipy-0.18.1-cp35-cp35m-win32.whl
Installing collected packages: scipy
Successfully installed scipy-0.18.1
Then there is only one more thing to do: comment out a specfic line or there will be error messages when you imput command "import scipy".
So comment out this line
from numpy._distributor_init import NUMPY_MKL # requires numpy+mkl
in this file: your_own_path\lib\site-packages\scipy__init__.py
Then you can use SciPy :)
Here tells you more about the last step.
Here is a similar anwser to a similar question.
Besides all of these answers,
If you install python of 32bit on your 64bit machine, you have to download scipy of 32-bit irrespective of your machine.
http://www.lfd.uci.edu/~gohlke/pythonlibs/
In the above URL you can download the packages and command is: pip install
For gentoo, it's in the main repository:
emerge --ask scipy
You can also use this in windows with python 3.6 python -m pip install scipy

How to install libjpeg?

I tried these commands:
pip install libjpeg8-dev
pip install libjpeg-dev
pip install libjpeg-devel
pip install libjpeg
pip install libjpeg62 libjpeg62-dev
but none of them works. What is the right command with pip?
Use apt-get. As a side note, I was getting errors installing pillow and these commands helped me
sudo apt-get install libjpeg-dev
sudo apt-get install zlib1g-dev
sudo apt-get install libpng-dev
libjpeg is not a python module and pip won't ever be able to install it.
Use your Operating System's packaging system to install it. On Ubuntu and Debian that'd be apt, for example.
I used homebrew to install that!
brew install libjpeg
Hope that helps
Actually I use Heroku and the problem therefore is more complicated. Here is a solution.
EDIT: but attempts to use both hg- and git-based variants failed with various errors. Damn!

How can I install python-iso8601_0.1.4-2_all.deb on Ubuntu 10.04 (lucid)

I am using Ubuntu 10.04, which supports Python up to version 2.6.5.
However, I need to install the package python-iso8601_0.1.4-2_all.deb,
which depends on python (>= 2.6.6-7~).
I can not upgrade the distro, since I am using some other packages
which are not supported in 10.10+
Thank you!
/Nico.
Thats likely to break far too many things. You are better of installing the ISO 8601 package as an egg from http://pypi.python.org/pypi/iso8601/ for example.
Install pip:
sudo apt-get install python-pip python-dev build-essential
sudo pip install --upgrade pip
sudo pip install --upgrade virtualenv
and then install your package:
sudo pip install iso8601

Categories