I'm curretnly trying to use PIL with PyPy3, but no matter how I try to install it I get an error. First I tried to install it normally using pypy3 pip install pillow, but got the error that I need zlib. So after searching for a solution for a while I found the easy_install pillow command which fixed this problem for most people, but for me it leads to the same error. I hope somebody can help me out.
Error:
File "C:\Users\name\AppData\Local\Temp\easy_install-uqrsyszz\Pillow-4.0.0\setup.py", line 791, in <module> setuptools.sandbox.UnpickleableException: RequiredDependencyException('\n\nThe headers or library files could not be found for zlib,\na required dependency when compiling Pillow from source.\n\nPlease see the install instructions at:\n http://pillow.readthedocs.io/en/latest/installation.html\n\n')
got it fixed by using pypy3 install pillow --global-option="build_ext" --global-option="--disable-zlib" --global-option="--disable-jpeg". :)
I was having a similar issue.
After some research, I found this solution which got me most of the way there. I had to perform step #4 below in addition to get it to work for me:
Install homebrew (if you don't already have it):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Brew install zlib:
brew install zlib
Set the following variables:
export LDFLAGS="-L/usr/local/opt/zlib/lib"
export CPPFLAGS="-I/usr/local/opt/zlib/include"
Brew install jpeg
brew install jpeg
Finally, pip install Pillow:
pip3 install Pillow==7.1.2
For linux debian based systems, the below solves the issue.
sudo apt install libjpeg-dev zlib1g zlib1g-dev
Related
I'm using mac osx 10.10
As the PyAudio Homepage said, I install the PyAudio using
brew install portaudio
pip install pyaudio
the installation of portaudio seems successful, I can find headers and libs in /usr/local/include and /usr/local/lib
but when I try to install pyaudio, it gives me an error that
src/_portaudiomodule.c:29:10: fatal error: 'portaudio.h' file not found
#include "portaudio.h"
^
1 error generated.
error: command 'cc' failed with exit status 1
actually it is in /usr/local/include
why can't it find the file?
some answers to similar questions are not working for me(like using virtualenv, or compile it manually), and I want to find a simple way to solve this.
Since pyAudio has portAudio as a dependency, you first have to install portaudio.
brew install portaudio
Then try: pip install pyAudio. If the problem persists after installing portAudio, you can specify the directory path where the compiler will be able to find the source programs (e.g: portaudio.h). Since the headers should be in the /usr/local/include directory:
pip install --global-option='build_ext' --global-option='-I/usr/local/include' --global-option='-L/usr/local/lib' pyaudio
On Ubuntu builds:
sudo apt-get install python-pyaudio
For Python3:
sudo apt-get install python3-pyaudio
You have to install portaudio first then link that file. Only then you can find that header file (i.e, portaudio.h). To install portaudio in mac by using HomeBrew program use following commands.
brew install portaudio
brew link portaudio
pip install pyaudio
sudo is not needed if you're admin. We should refrain using sudo as it messes up lots of permissions.
First, you can use Homebrew to install portaudio.
brew install portaudio
Then try to find the portaudio path:
sudo find / -name "portaudio.h"
In my case it is at /usr/local/Cellar/portaudio/19.6.0/include .
Run the command below to install pyaudio
pip install --global-option='build_ext' --global-option='-I/usr/local/Cellar/portaudio/19.6.0/include' --global-option='-L/usr/local/Cellar/portaudio/19.6.0/lib' pyaudio
On Raspbian:
sudo apt-get install python-pyaudio
on Centos:
yum install -y portaudio portaudio-devel && pip install pyaudio
Just for the record for folks using MacPorts and not Homebrew:
$ [sudo] port install portaudio
$ pip install pyaudio --global-option="build_ext" --global-option="-I/opt/local/include" --global-option="-L/opt/local/lib"
I needed to do the following to install PortAudio on Debian
sudo apt install portaudio19-dev
I also apt install'd python3-portaudio before that, although it didn't work. I'm not sure if that contributed as well.
Adding a bit of robustness (in case of a non-default homebrew dir) to the snippet from #fukudama,
brew install portaudio
pip install --global-option='build_ext' --global-option="-I$(brew --prefix)/include" --global-option="-L$(brew --prefix)/lib" pyaudio
For me on 10.10.5 the paths were under /opt/local. I had to add /opt/local/bin to my /etc/paths file. And the command line that worked was
sudo pip install --global-option='build_ext' --global-option='-I/opt/local/include' --global-option='-L/opt/local/lib' pyaudio
this is the tested answer for MacBook Pro m2 chip:
first find the location of the portaudio.h file by
sudo find / -name "portaudio.h"
then, once you find the location, copy it and use it in this command.
LDFLAGS="-L/{opt/homebrew/Cellar/portaudio/19.7.0/}lib" CFLAGS="-I/{opt/homebrew/Cellar/portaudio/19.7.0}/include" pip3 install pyaudio
Here replace the location from { } into you file location hopefully this works. I have tried above solutions and this one worked for me.
If you are using anaconda/miniconda to manage your python environments then
conda install pyaudio
installs portaudio at the same time as pyaudio
The following NEW packages will be INSTALLED:
portaudio pkgs/main/osx-64::portaudio-19.6.0-h647c56a_4
pyaudio pkgs/main/osx-64::pyaudio-0.2.11-py37h1de35cc_2
On Termux (this is what worked for me):
pkg install python
bash -c "$(curl -fsSL https://its-pointless.github.io/setup-pointless-repo.sh)"
pkg install portaudio
pip install pyaudio
Source: pyaudio installing #6235
For M1 mac, this is worked for me:
LDFLAGS="-L/opt/homebrew/Cellar/portaudio/19.7.0/lib" CFLAGS="-I/opt/homebrew/Cellar/portaudio/19.7.0/include" pip3 install pyaudio
Res:
Created wheel for pyaudio: filename=PyAudio-0.2.12-cp310-cp310-macosx_11_0_arm64.whl size=24170 sha256=c74eb581e6bca2400f681f68d33654002722969f1a455ffce87e4e5da05471d8
Stored in directory: /private/var/folders/m_/kzyr4q_11cl35ngrj77k28f00000gn/T/pip-ephem-wheel-cache-ql1x8ums/wheels/93/08/0b/b915ab1895927641737175e5bc7b6111e8ed0c26daabeecba0
Successfully built pyaudio
Installing collected packages: pyaudio
Successfully installed pyaudio-0.2.12
Be noted, do not using find / its very slow and stupid, using brew info portaudio
I was following the instructions here and I'm having trouble getting the installation to work. Basically, the first part works fine. I downloaded portaudio, followed the instructions, and it all seemed to work.
However, when I triedpython3 setup.py install, I got an error. The error came from the /src/_portaudiomodule.c file, and it said that "The file Python.h could not be found". I don't really understand what's going on because there was no Python.h file when I extracted the PyAudio archive. I don't know where the Python.h file was supposed to come from.
I'm kind of a noob to unix systems so I could have easily made a mistake somewhere. I've been trying to solve this for hours and I've had no luck so far. Thanks in advance for your help!
To install the latest version of pyaudio using conda:
source activate -your environment name-
pip install pyaudio
You may run into the following error when installing from pip:
src/_portaudiomodule.c:29:23: fatal error: portaudio.h: No such file or directory
#include "portaudio.h"
compilation terminated.
error: command 'gcc' failed with exit status 1
That is because you don't have the PortAudio development package installed. Install it with:
sudo apt-get install portaudio19-dev
You don't need to compile pyaudio. To install PyAudio, run:
$ sudo add-apt-repository universe
$ sudo apt-get install python-pyaudio python3-pyaudio
The first command enables Universe Ubuntu repository.
If you want to compile it e.g., to use the latest version from git; install build dependencies:
$ sudo apt-get build-dep python-pyaudio python3-pyaudio
After that, you could install it from sources using pip:
$ python3 -mpip install pyaudio
Or to install the current version from git:
$ pip install -e git+http://people.csail.mit.edu/hubert/git/pyaudio.git#egg=pyaudio
Run pip commands inside a virtualenv or add --user command-line option, to avoid modifying the global python3 installation (leave it to the package manager).
I've tested it on Ubuntu. Let me know if it fails on Mint.
I have found the work arround for mac.
please refer the below steps to install pyaudio on python 3.5
Follow these steps :
export HOMEBREW_NO_ENV_FILTERING=1
xcode-select --install
brew update
brew upgrade
brew install portaudio
pip install pyaudio
I was able to get it install with anaconda, using this package.
Follow install instructions for linux here, then do:
conda install -c bokeh pyaudio=0.2.7
try to install using the the below command
pip install pyaudio
after that install the required Microsoft Visual C++ 14.0
refer the below image for the same.
and restart the system and run the same command again
pip install pyaudio
Python.h is nothing but a header file. It is used by gcc to build applications. You need to install a package called python-dev. This package includes header files, a static library and development tools for building Python modules, extending the Python interpreter or embedding Python in applications. To install this package, enter:
sudo apt-get install python3-dev
The question is why I see the error message in the title when trying to import enchant. I am using Win64.
On Ubuntu, run sudo apt-get install libenchant1c2a
I found the answer in this GitHub page.
In a nutshell, they have not shipped a wheel for the win_amd64 platform yet.
Resolved: On Win7-64 I ran
pip3 install pyenchant==1.6.6
which seems to be the latest version of PyEnchant that still shipped with Win-64 binaries. Newer versions did not install for me, but this one did.
For amazon ubuntu instance use.
yum install enchant
and then
pip install pyenchant
For me, the problem I ran into was that I had an old version of pip. I installed the latest version and was able to download the pyenchant library.
pip install -U pip
On Windows x64 I've solved this problem as follows:
Click link https://pypi.org/project/pyenchant/#files and download pyenchant-2.0.0.win32.exe
Launch it and while installing it using the installation wizard you must specify your python interpreter location which in my case is:
C:\Users\Asus\AppData\Local\Programs\Python\Python36\python.exe
Important:İf you use python32 interpreter you must specify this location:
C:\Users\Asus\AppData\Local\Programs\Python\Python36-32\python.exe
if you use python 3.5 interpreter version your location may be like this:
C:\Users\Asus\AppData\Local\Programs\Python\Python35\python.exe
and finish the installation. Pip commands will work now for other dependency packages.
On MacOS, you can install it via brew:
brew install enchant
pip install pyenchant
To run with docker on AWS:
With apt-get:
sudo apt-get update
sudo apt-get -y install enchant-2
With apt:
sudo apt update
sudo apt -y install enchant-2
Thank you
I have fix the bugs on the colab.
!apt update
!apt install enchant --fix-missing
After fixing the missing files, you could run the enchant.
I've just updated my Mac OS to 10.9 and I discovered that some (all?) of my Python modules are not here anymore, especially the Image one.
So I try to execute sudo pip install pil, but I get this error:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/tk.h:78:11: fatal error: 'X11/Xlib.h' file not found
# include <X11/Xlib.h>
^
1 error generated.
error: command 'cc' failed with exit status 1
My Xcode is up-to-date and I don't have any idea. Is it possible that PIL is not yet 10.9 compatible ?
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
open your terminal and execute:
xcode-select --install
sudo ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11/ /usr/local/include/X11
helps for me!
os x 10.9
pip install pillow
but! after pip install ...
*** ZLIB (PNG/ZIP) support not available
and finally i fix it by running:
xcode-select --install
then reinstall pillow
pip install pillow
PIL SETUP SUMMARY
--------------------------------------------------------------------
version Pillow 2.2.1
platform darwin 2.7.5 (default, Aug 25 2013, 00:04:04)
[GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.0.68)]
--------------------------------------------------------------------
--- TKINTER support available
--- JPEG support available
--- ZLIB (PNG/ZIP) support available
--- TIFF G3/G4 (experimental) support available
--- FREETYPE2 support available
--- LITTLECMS support available
--- WEBP support available
--- WEBPMUX support available
--------------------------------------------------------------------
Works for me ( OS X Yosemite 10.10.2 - Python 2.7.9 ) :
xcode-select --install
sudo pip install pillow
Try this to check it:
from PIL import Image
image = Image.open("file.jpg")
image.show()
Here is what I did, some steps may not be necessary just for PIL but I needed libpng and others anyways:
1) Run xcode install, use this command or download updates from the app store:
xcode-select --install
1b) Add the Command Line Tools optional tool, in Mountain Lion this was an option on the xcode Download page, but now you have to register with your apple id and download from: https://developer.apple.com/downloads/
Look for Command Line Tools (OS X Mavericks) for Xcode
2) Install everything needed for python (using brew), I believe you can use port as well:
brew install readline sqlite gdbm
brew install python --universal --framework
brew install libpng jpeg freetype
Unlink/ relink if needed i.e. if upgrading.
3) Install Pip and required modules:
easy_install pip
sudo pip install setuptools --no-use-wheel --upgrade
4) Finally this works with no errors:
sudo pip install Pillow
UPDATE 11/04/14: PIL repo no longer receives updates or support so Pillow should be used. The below is now deprecated so stick with Pillow.
sudo pip install pil --allow-external pil --allow-unverified pil
UPDATE (OLD) : The same thing applies when installing Pillow (PIL fork) and should be mentioned as its quickly becoming a replacement in most cases of PIL. Instead of installing pip in step 4, run this instead:
sudo pip install Pillow
Hope this helps someone!
installing command line tools fixed the issue for me
you have to install them separately as they are not part of the packages in xcode now:
https://developer.apple.com/downloads/index.action?=command%20line%20tools#
Non of those worked for me.. I kept receiving:
clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future]
clang: note: this will be a hard error (cannot be downgraded to a warning) in the future
error: command 'cc' failed with exit status 1
So I found a work around with the following solution:
sudo export CFLAGS=-Qunused-arguments
sudo export CPPFLAGS=-Qunused-arguments
sudo pip install PIL --allow-external PIL --allow-unverified PIL
This way I was able to install.
I had a similar problem: Installing pillow failed with clang: error: unknown argument: '-mno-fused-madd' [-Wunused-command-line-argument-hard-error-in-future], installing command line tools failed with Can't install the software because it is not currently available from the Software Update server., and even after installing the command line tools manually, the compilation of PIL failed.
This happens cause clang under the newest version of xcode doesn't warn on unknown compiler flags, but rather stop the compilation with a hard error.
To fix this, just run export ARCHFLAGS="-Wno-error=unused-command-line-argument-hard-error-in-future" on the terminal before trying to compile (installing pil).
Simply run
pip install pil --allow-external pil --allow-unverified pil
This my steps on mac os 10.9.1
1. sudo su
2. easy_install pip
3. xcode-select --install
4. pip install --no-index -f http://dist.plone.org/thirdparty/ -U PIL
You could use Homebrew to do the install http://brew.sh
brew tap Homebrew/python
brew install pillow
Make sure you have Command Line Tools installed on your xcode. Then execute:
sudo pip install pil --allow-external pil --allow-unverified pil
I was having the following error
building 'PIL._imagingft' extension
_imagingft.c:62:10: fatal error: 'freetype/fterrors.h' file not found
#include <freetype/fterrors.h>
^
1 error generated.
error: command 'cc' failed with exit status 1
The solution to this was to symlink freetype2 to freetype and this solved the problem.
I didn't want to install XCode (I don't use it) and I'm loath to fiddle with Application directory. I've cribbed from the many answers in this post and the following two steps work for me with 10.9.5:
sudo easy_install pip
sudo pip install pillow
It did appear to me strange that I had to use easy_install to install pip. But pip didn't want to work for me before that (re-)install.
Found the solution ... You've to symlink X11 like this ln -s /opt/X11/include/X11 /usr/local/include/X11 and then sudo pip install pil should work.
Reusing #DmitryDemidenko's answer that is how it 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
and then
sudo pip install -U PIL --allow-external PIL --allow-unverified PIL
Execute the bellow command lines. Works like a charm on Mac OS 10.9.5
easy_install pip
sudo pip install setuptools --no-use-wheel --upgrade
sudo pip install Pillow
Best,
Theo
That's what I did:
First upgrade to Xcode 5 (I am running 10.9). Then, execute the following commands in a terminal:
$ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk
$ 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/include/
A more complete solution requires the installation of the Xquartz X11 subsystem that has been built outside of Apple for several years now. Here are the steps I used to get it all working
Install XQuartz from http://xquartz.macosforge.org/landing/
Run sudo pip install pillow
As the accepted answer is the right one with xcode-select --install but some people (including me) may encounter Can't install the software because it is not currently available from the Software Update server
If you are using beta software (as I am using Yosemite now and had the same problem) you NEED to get the CLT separately since it is NOT included in XCode (even xcode beta)
Head over to developers.apple.com and get CLT tools for your OS ;)
P.S. You don't need XQuartz for PIL or Pillow to work
My machine which was recently upgraded from OS 10.8 -> 10.9 got stuck in a loop between xcrun and lipo.
Rename /usr/bin/lipo to /usr/bin/lipo_broken
Refer to this thread for further information on how to resolve:
xcrun/lipo freezes with OS X Mavericks and XCode 4.x
Install Pillow instead:
sudo pip install pillow
ln -s /usr/local/include/freetype2 /usr/local/include/freetype
sudo ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install pil
Try this:
ln -s /usr/local/include/freetype2 /usr/local/include/freetype
sudo pip uninstall pillow
pip install pillow
worked for me. I'm running Python 2.7.9 on Yosemite.import PIL now works for me.
Installing PIL (Imaging.1.1.7) on Mac OSC 10.10 Yosemite. I tried numerous fixes recommended here but ran into trouble with each one. I finally solved this problem by editing the setup.py file such that:
TCL_ROOT = "/opt/X11/include"
which passes the appropriate include path for X11 in the compilation of _imagingtk.c, which was causing the problem for me. Worked immediately after change.
I've moved from pyenv to virtualenv and this fixed my problem.
ln -s /opt/X11/include/X11 /usr/local/include/X11
pip install pil without sudo
I've created virtualenv for Python 2.7.4 on Ubuntu 13.04. I've installed python-dev.
I have the error when installing numpy in the virtualenv.
Maybe, you have any ideas to fix?
The problem is SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
so do the following in order to obtain 'Python.h'
make sure apt-get and gcc are up to date
sudo apt-get update
sudo apt-get upgrade gcc
then install the python2.7-dev
sudo apt-get install python2.7-dev
and I see that you have most probably already done the above things.
pip will eventually spit out another error for not being able to write into /user/bin/blahBlah/dist-packages/ or something like that because it couldn't figure out that it was supposed to install your desiredPackage (e.g. numpy) within the active env (the env created by virtualenv which you might have even changed directory to while doing all this)
so do this:
pip -E /some/path/env install desiredPackage
that should get the job done... hopefully :)
---Edit---
From PIP Version 1.1 onward, the command pip -E doesn't work. The following is an excerpt from the release notes of version 1.1 (https://pip.pypa.io/en/latest/news.html)
Removed -E/--environment option and PIP_RESPECT_VIRTUALENV; both use a restart-in-venv mechanism that's broken, and neither one is useful since every virtualenv now has pip inside it. Replace pip -E path/to/venv install Foo with virtualenv path/to/venv && path/to/venv/pip install Foo
If you're on Python3 you'll need to do sudo apt-get install python3-dev. Took me a little while to figure it out.
If you're hitting this issue even though you've installed all OS dependencies (python-devel, fortran compiler, etc), the issue might be instead related to the following bug:
"numpy installation thru install_requires directive issue..."
Work around is to manually install numpy in your (virtual) environment before running setup.py to install whatever you want to install that depends on numpy.
eg, pip install numpy then python ./setup.py install
This answer is for those of us that compiled python from source or installed it to a non standard directory. In my case, python2.7 was installed to /usr/local and the include files were installed to /usr/local/include/python2.7
C_INCLUDE_PATH=/usr/local/include/python2.7:$C_INCLUDE_PATH pip install numpy
I recently had the same problem. I run Debian Jessie and tried to install numpy from a Python 2.7.9 virtualenv. I got the same error -- numpy complaining that Python.h is missing while python2.7-dev and gcc are already installed.
File "numpy/core/setup.py", line 42, in check_types
],
File "numpy/core/setup.py", line 293, in check_types
SystemError: Cannot compile 'Python.h'. Perhaps you need to install python-dev|python-devel.
I'm running pip 1.5.6 and it doesn't appear to have command line option '-E'
$ pip -V
pip 1.5.6 from /home/alex/.virtualenvs/myenv/local/lib/python2.7/site- packages (python 2.7)
Upgrading pip to the latest verson 7.0.3 solves the problem
$ pip install --upgrade pip
Downloading/unpacking pip from https://pypi.python.org/packages/py2.py3/p/pip/pip-7.0.3-py2.py3-none-any.whl#md5=6950e1d775fea7ea50af690f72589dbd
Downloading pip-7.0.3-py2.py3-none-any.whl (1.1MB): 1.1MB downloaded
Installing collected packages: pip
Found existing installation: pip 1.5.6
Uninstalling pip:
Successfully uninstalled pip
Successfully installed pip
Cleaning up...
Now it is possible to install numpy
$ pip install numpy
Collecting numpy
Downloading numpy-1.9.2.tar.gz (4.0MB)
100% |████████████████████████████████| 4.0MB 61kB/s
Installing collected packages: numpy
Running setup.py install for numpy
Successfully installed numpy-1.9.2
This is probably because you do not have the python-dev package installed. You can install it like this:
sudo apt-get install python-dev
You can also install it via the Software Center:
#samkhan13 solution didn't work for me as pip said it doesn't have the -E option.
I was still getting the same error, but what worked for me was to install matplotlib, which installed numpy.