How to install pil
How to install pil
How to Install PIL on Linux?
PIL is an acronym for Python Image Library. It is also called Pillow. It is one of the most famous libraries for manipulating images using the python programming language. It is a free and open-source Python library.
Installing PIL on Linux:
Method 1: Using PIP command:
Step 1: Open up the Linux terminal and type the following command and hit enter.
Output:
Step 2: To check if PIL is successfully installed, open up the python terminal by typing python3 in the terminal. This will open up the python3 interactive console now type the following command to check the current version of the PIL.
This will output the currently installed version of the PIL.
Output:
Method 2: Using aptitude package manager
Aptitude is just a frontend version of the apt command that we used to install packages. Aptitude is an interactive package manager, it provides a list of all the matching packages that we want to install. It also finds and installs all the required dependencies for the package.
Step 1: Run the following command to install the PIL using Aptitude.
How do I install PIL/Pillow for Python 3.6?
I have a script that requires PIL to run. Other than downgrading my Python, I couldn’t find anyway to install PIL on my Python 3.6
Here are my attempts:
64-bit Windows 10 & Python 3.6
3 Answers 3
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
For python version 2.x you can simply use
But for python version 3.X you need to specify
when you enter pip in bash hit tab and you will see what options you have
You can download the wheel corresponding to your configuration here («Pillow‑4.1.1‑cp36‑cp36m‑win_amd64.whl» in your case) and install it with:
pip install some-package.whl
If you have problem to install the wheel read this answer
Pillow is released with installation wheels on Windows:
We provide Pillow binaries for Windows compiled for the matrix of supported Pythons in both 32 and 64-bit versions in wheel, egg, and executable installers. These binaries have all of the optional libraries included
Update: Python 3.6 is now supported by Pillow. Install with pip install pillow and check https://pillow.readthedocs.io/en/latest/installation.html for more information.
However, Python 3.6 is still in alpha and not officially supported yet, although the tests do all pass for the nightly Python builds (currently 3.6a4).
If it’s somehow possible to install the 3.5 wheel for 3.6, that’s your best bet. Otherwise, zlib notwithstanding, you’ll need to build from source, requiring an MS Visual C++ compiler, and which isn’t straightforward. For tips see:
And also see how it’s built for Windows on AppVeyor CI (but not yet 3.5 or 3.6):
Failing that, downgrade to Python 3.5 or wait until 3.6 is supported by Pillow, probably closer to the 3.6’s official release.
How To Install PIL On Ubuntu
Let’s say you want to play around with images in Python. To do that, we need a Python package that can handle all the image manipulation. Python Imaging Library (PIL) is one of most popular libraries that is used to process the image data. Actually, people use Pillow now, which is a modern repackaged version of PIL. It has a lot of nice functionalities and it works well. Let’s see how you can install PIL on 64-bit Ubuntu 12.04.
If you don’t have pip, install it using:
With pip installed, install the required development packages:
Once you install these packages, we have to symlink the three image libraries into /usr/lib. Wait, now what is “symlink”? A symlink, which is short for symbolic link, is a special type of file that contains a reference to another file or directory. The reference is in the form of an absolute or relative path and it affects path-name resolution. To do that, type in the following commands on the terminal:
Now we are ready to install PIL. Type the following:
To install Pillow (recommended), type the following:
PIL (or Pillow) should now install with support for JPEGs, PNGs and FreeType, as indicated by the compilation output:
I see some errors. What do I do?
Here is the solution to some of the common problems you might face.
Missing image libraries : If the image libraries are not installed and available in /usr/lib, you’ll see something like this:
To add a missing option, make sure you have the required library, and set the corresponding ROOT variable in the setup.py script.
Missing python headers : Make sure you have python-dev. Without it, you’ll see something that ends with the following:
how to install PIL with pip?
when I run the following
but I already install Pillow and everything is fine.
3 Answers 3
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
Use Pillow which is the «new» or the replacement of PIL, but has the same-named modules to preserve compatibility:
Also, as suggested in the comments, maybe you are just using the wrong python binary, try to check if you’re in/out of a virtual environment or check differences between python vs python3 vs python2 on your system:
The problem is that you are not running the same python interpreter. In addition, the problem could arise from this fact that python cannot find the path to the OpenCV.
You first need to find the path to the OpenCV installed on your OS.
First, open a python script and run this:
This will print the PATH to the OpenCV installed on your OS.
Then, add the following two lines to the top of your main script (before calling tkinter and PIL):
Alternative Solution:
The problem could be that you are not running the same python interpreter.
You first need to find the path to the python executable that is interpreting your python scripts.
Open a python script and run this:
This will print the path to the python executable that is interpreting your python scripts.
Now, you can install pillow in the found path as follows:
How to install PIL with pip on Mac OS?
I am trying to install PIL (the Python Imaging Library) using the command:
but I get the following message:
21 Answers 21
Trending sort
Trending sort is based off of the default sorting method — by highest score — but it boosts votes that have happened recently, helping to surface more up-to-date answers.
It falls back to sorting by highest score if no posts are trending.
Switch to Trending sort
If you have both Pythons installed and want to install this for Python3:
10 different libraries on your dev build just to start debugging the one-line error that is occurring in the production environment. Hope this clarifies.
This works for me:
It is very simple using apt install use this command to get it done
Then, Just import in your file like,
I am using windows. It is working for me.
Pillow is a functional drop-in replacement for the Python Imaging Library. To run your existing PIL-compatible code with Pillow, it needs to be modified to import the Imaging module from the PIL namespace instead of the global namespace.
from PIL import Image
You should install as described here:
On Mac OS X, use this command:
I got the answer from a discussion here:
Alternatively, you can just download/build/install it from source:
I ran the above just now (on OSX 10.7.2, with XCode 4.2.1 and System Python 2.7.1) and it built just fine, though there is a possibility that something in my environment is non-default.
Источники информации:
- http://stackoverflow.com/questions/39179948/how-do-i-install-pil-pillow-for-python-3-6
- http://prateekvjoshi.com/2014/04/19/how-to-install-pil-on-ubuntu/
- http://stackoverflow.com/questions/68439152/how-to-install-pil-with-pip
- http://stackoverflow.com/questions/20060096/how-to-install-pil-with-pip-on-mac-os