installing libicu-dev on mac - python

how do i install libicu-dev on mac. This is the instruction recommended on the documentation
sudo apt-get install python-numpy libicu-dev
http://polyglot.readthedocs.org/en/latest/Installation.html
I am using anaconda but it seems to always throw up an
In file included from _icu.cpp:27:
./common.h:86:10: fatal error: 'unicode/utypes.h' file not found
#include <unicode/utypes.h>
error

I just got PyICU to install on OSX, after it was failing due to that same error. Here is what I recommend:
Install homebrew (package manager for OSX)
brew install icu4c # Install the library; may be already installed
Verify that the necessary include directory is present: ls -l /usr/local/opt/icu4c/include/
If you do not have that directory, you may need to reinstall icu4u. I found that I had to do the following:
brew remove icu4c
brew install icu4c
Try to install polyglot to see if it can find icu4c: pip install polyglot
If that still complains, you can try specifying library location: CFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib pip install polyglot
EDIT: There have been further changes. My current process for installing icu:
brew install icu4c
brew link icu4c --force
ICU_VERSION=<BREW_ICU_VERSION> CFLAGS=-I/usr/local/opt/icu4c/include LDFLAGS=-L/usr/local/opt/icu4c/lib pip install pyicu

brew install icu4c
brew link icu4c --force
https://github.com/imojiengineering/node-icu-tokenizer

for me the simple answer with just brew install and linking does not work so I found the below solution to make it works:
1) install icu4c with brew:
brew install icu4c
2) check the version:
ls /usr/local/Cellar/icu4c/
it prompts something like:
59.1
3) execute bellow commands with substitution of proper version from previous step (first line only integer part, second and third line with decimal part):
export ICU_VERSION=59
export PYICU_INCLUDES=/usr/local/Cellar/icu4c/59.1/include
export PYICU_LFLAGS=-L/usr/local/Cellar/icu4c/59.1/lib
4) finally install python package for pyicu:
pip install pyicu

Related

python_qpid_proton for mac using amqps

I'm trying to install python_qpid_proton on Mac OS X El Capitan and I'm having trouble getting it to find the SSL libraries when I actually make a connection.
When trying to use the library, I get this error attempting to connect using amqps:
proton.SSLUnavailable: amqps: SSL libraries not found
I've installed OpenSSL using the latest version of homebrew and have this in my .bashrc file:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
I've also tried rebuilding python_qpid_proton using both pip and the setup.py file and also examined the output from the setup.py install run to see if there was any sort of warning or error and did not see any.
I had a similar issue. Here's how I fixed it on my Mac OS Sierra. I guess you run into the same issue with El Capitan. By running the install in verbose mode I recognised missing dependencies. The following actions fixed it on my end:
Uninstall python-qpid-proton:
pip uninstall python-qpid-proton
Install missing dependencies (swig + pkg-config) via brew:
brew install swig
brew install pkg-config
Install python-qpid-proton and pip disable cache to force rebuild of lib:
export CFLAGS="-I/usr/local/opt/openssl/include"; pip install python-qpid-proton --verbose --no-cache-dir
In my case the solution was the following
pip uninstall python-qpid-proton
then install required
brew install swig
brew install pkg-config
and the setup flags:
export LDFLAGS="-L/usr/local/opt/openssl/lib"
export CPPFLAGS="-I/usr/local/opt/openssl/include"
export PKG_CONFIG_PATH="/usr/local/opt/openssl/lib/pkgconfig"
and finally compile as stated before:
export CFLAGS="-I/usr/local/opt/openssl/include"; pip install python-qpid-proton --verbose --no-cache-dir

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

Fail during installation of Pillow (Python module) in Linux

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

how to install python packages for brew installed pythons

I just finished installing the latest stable version of python via Homebrew.
$ brew install python3
Everything works fine. I would like to install packages, for example PyMongo.
I don't have pip.
$ pip
-bash: pip: command not found
and there is no Homebrew formulae for it:
$ brew install PyMongo
brew install PyMongo
Error: No available formula for pymongo
Searching formulae...
Searching taps...
Any idea what's the best way to install PyMongo on OS X when Python was installed via Homebrew. Thank you!
Use pip3. The "caveats" text you see when you run brew info python3 was printed for you after python3 was installed; that text is frequently helpful! It reads:
You can install Python packages with
pip3 install <package>
They will install into the site-package directory
/usr/local/lib/python3.4/site-packages

Error when install pylibmc using pip

Hello when I attempt to install pylibmc on OSX Lion using pip I get the following error:
./_pylibmcmodule.h:42:10: fatal error: 'libmemcached/memcached.h' file not found
#include <libmemcached/memcached.h>
^
1 error generated.
error: command 'clang' failed with exit status 1
Any clues at how to solve this issue?
libmemcached may also be installed using Homebrew.
brew install libmemcached
After that, pip install pylibmc worked for me without needing to specify any additional arguments.
It's in the libmemcached package. To install it using macports:
sudo port install libmemcached
Then, assuming you're using pip:
pip install pylibmc --install-option="--with-libmemcached=/opt/local"
or
LIBMEMCACHED=/opt/local pip install pylibmc
as explained in the pylibmc docs.
I solved this issue by checking where memcached is installed
$ which memcached
/usr/local/bin/memcached
and then setting LIBMEMCACHED environment variable before pip install:
$ export LIBMEMCACHED=/usr/local
$ pip install pylibmc
Answer for Ubuntu users:
sudo apt install libmemcached-dev zlib1g-dev
I have the same problem because i have installed MEMCACHED and not LIBMEMCACHED, so, to resolve:
brew uninstall memcached #to remove wrong package
brew install libmemcached #install correct lib
pip install pylibmc
Its Works for me!
: )
For those finding this answer on Fedora:
sudo yum install libmemcached-devel
Hit the same error with macOS High Sierra, Python3.6 installed with brew. Solution for me was to export these flags, mentioned in this comment: Error when install pylibmc using pip
export LDFLAGS="-L/usr/local/lib"
export CPPFLAGS="-I/usr/local/include"
After that, pip install run just fine.
i fixed this by installing memcached from port
you should install first macports from http://www.macports.org/
then run this command
sudo port install memcached
after that download the pylibmc from the pypi http://pypi.python.org/pypi/pylibmc
extract .tar.gz file then
python setup.py install --with-libmemcached=/opt/local
this code is worked for me
sudo apt-get install libmemcached-dev zlib1g-dev
LIBMEMCACHED=/opt/local pip install pylibmc
Sometimes the X-Code Command Line Tools need to be installed.
xcode-select -p

Categories