How to Install Pil with Pip on MAC Os

How to install PIL to Python 3.5 on a mac?

On your command line:

$ which python

I'm betting that this returns:

/Library/Python/2.7/site-packages

This shows your 'basic' Python (which comes preinstalled on Mac) location. Now do:

$ which python3

If that shows this:

/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5'

Then check for a pip3 version:

$ which pip3

If that exists and has a similar location to python3, then try this:

$ pip3 install Pillow

If that works, there is a good chance PyCharm will now pick up the correct installation.

How can I install PIL on mac os x 10.7.2 Lion

If you use homebrew, you can install the PIL with just brew install pil. You may then need to add the install directory ($(brew --prefix)/lib/python2.7/site-packages) to your PYTHONPATH, or add the location of PIL directory itself in a file called PIL.pth file in any of your site-packages directories, with the contents:

/usr/local/lib/python2.7/site-packages/PIL

(assuming brew --prefix is /usr/local).

Alternatively, you can just download/build/install it from source:

# download
curl -O -L http://effbot.org/media/downloads/Imaging-1.1.7.tar.gz
# extract
tar -xzf Imaging-1.1.7.tar.gz
cd Imaging-1.1.7
# build and install
python setup.py build
sudo python setup.py install
# or install it for just you without requiring admin permissions:
# python setup.py install --user

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.

Installing PIL on mac OS

I solved the X11 compiler error by doing xcode-select --install

Found the answer here: https://stackoverflow.com/a/43716118/310159

Can't install PIL after Mac OS X 10.9

Following worked for me:

ln -s  /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11 /usr/local/include/X11
sudo pip install pil

UPDATE:

But there is more correct solution below, provided by Will.

open your terminal and execute:
xcode-select --install

Can't install PIL on MAC OS X 10.12

You have both Python 2 and Python 3 installed.
Python 2 comes with macos. So the program python is probably a link to python2.7.

You didn't mentioned how you installed Python 3. If you haven't done so, it is probably easiest in the long run is to use a package manager like homebrew.

This is because an imaging library like Pillow needs certain shared libraries to work properly. Homebrew's recipes will make sure that these are installed when you install pillow.
The same goes for other useful packages like numpy.

So, delete your Python 3 version. Install homebrew and use it to install Python 3 and pillow.

how to install PIL on python shell on OS X 10.9.5

You should run the pip command from a system terminal (BASH prompt), not from inside Python. Normally you would open /Applications/Utilities/Terminal.app, and then type pip install PIL. If that installs packages for Python 2.7 instead of 3.5, you could try this instead: python3 $(which pip) install PIL.

Or from within Python 3.5 you could try this (from Installing python module within code):

import pip
pip.main(['install', 'PIL'])

A longer-term solution would be to install pip to work with Python 3.5 instead of 2.7. To do that, you would run these commands from the system terminal:

curl --remote-name https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py

Then pip install PIL should install PIL in your 3.5 installation.

Installing PIL to use with Django on Mac OS X

EDIT: This answer has been getting voted up recently, and I want to modify it to reflect what I'm doing now.

Firstly, I've switched from MacPorts to Homebrew for package management on Mac OS X. Secondly, I've switched from using my package manager to using pip and virtualenvwrapper to manage my Python libraries.

Why I switched:

At first, with just a few Django projects, it was very easy to keep everything up to date using MacPorts. It was also fairly easy to have multiple versions of Python using python_select. What I didn't realize was that I was doing a pretty terrible job of keeping multiple libraries working side-by-side. It became obvious as I upgraded my packages that sometimes I really didn't want a project's Django version to change. After a couple of Django 1.1 projects (now running Django 1.3) started exhibiting weird behaviour (forms failing to submit because of CSRF middleware changes, small differences in Django libraries, admin app assets changing, and so on) it became clear that I should look into a better solution.

What I do now:

On Mac OS X I'm moved over to using pip and virtualenvwrapper. First off, I install virtualenvwrapper:

pip install virtualenvwrapper

This will grab virtualenv and virtualenvwrapper. You then need to add the following to your .bashrc or .profile and source it or open a new shell.

export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh # where Homebrew places it
export VIRTUALENVWRAPPER_VIRTUALENV_ARGS='--no-site-packages' # optional

Line 1 sets up the variable workon needs to find its files. Line 2 points to the main shell script (the path here is where Homebrew places the file, it might be different if you're using another package manager). Line 3 is optional, but I really like it: it makes sure that no currently installed libraries in the "main" site-packages repository will leak into your newly created virtual environment. I find this keeps things clean and leads to fewer surprises down the road as things are upgraded.

The next step is to create a new virtual environment:

mkvirtualenv testEnvironmentName

After making the environment, you'll be placed into it. If you kept the --no-site-packages flag, you can type pip freeze to see that your Python library slate is now blank. To escape from the virtual environment, use the deactivate command. To get into your virtualenv again, use workon testEnvironmentName. Note that you can use tab completion on the name of the environment. Also note that typing workon by itself will give you a list of available environments. From here you can pip install any libraries you want, including PIL.

To learn more about virtualenvwrapper, I recommend checking out the documentation.

Here's another great resource which taught me a lot about using virtualenvwrapper (or just view the screencast)


ORIGINAL:

You can also instal PIL using MacPorts. The package name is py-pil. Here's more information on the package. I'm pretty fond of MacPorts over pip, as I find it gives me a bit more configurability when it comes to keeping several versions of python and several libraries installed.

Here are the installation instructions for MacPorts: http://www.macports.org/install.php

See also: What is the most compatible way to install python modules on a Mac?



Related Topics



Leave a reply



Submit