Installing Python libraries using Pip - python

thanks in advance for any help!
I'm trying to install a set of Python 2.7.5 libraries using Pip 1.5.2. I'm following the directions to install NuPIC on my mac (OS X Mavericks).
Everything was going fine until I ran this line:
sudo pip install --allow-all-external --allow-unverified PIL --allow-unverified psutil -r $NUPIC/external/common/requirements.txt
I got this error:
building '_imagingft' extension
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -I/System/Library/Frameworks/Tcl.framework/Headers -I/System/Library/Frameworks/Tk.framework/Headers -I/usr/local/include/freetype2 -IlibImaging -I/System/Library/Frameworks/Python.framework/Versions/2.7/include -I/usr/local/include -I/usr/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imagingft.c -o build/temp.macosx-10.9-intel-2.7/_imagingft.o
clang: warning: argument unused during compilation: '-mno-fused-madd'
_imagingft.c:73:10: fatal error: 'freetype/fterrors.h' file not found
#include <freetype/fterrors.h>
^
1 error generated.
error: command 'cc' failed with exit status 1
----------------------------------------
Cleaning up...
Command /usr/bin/python -c "import setuptools, tokenize;__file__='/private/tmp/pip_build_root/PIL/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-vJHHeE-record/install-record.txt --single-version-externally-managed --compile failed with error code 1 in /private/tmp/pip_build_root/PIL
Storing debug log for failure in /Users/aaronclaytondunn/Library/Logs/pip.log
And here's the requirements file ($NUPIC/external/common/requirements.txt):
#See http://www.pip-installer.org/en/latest/requirements.html for details
asteval==0.9.1
mock==1.0.1
ordereddict==1.1
PIL==1.1.7
psutil==1.0.1
pylint==0.28.0
pytest==2.4.2
pytest-cov==1.6
pytest-xdist==1.8
python-dateutil==2.1
PyYAML==3.10
unittest2==0.5.1
validictory==0.9.1
PyMySQL==0.5
DBUtils==1.1
numpy==1.7.1
tweepy==2.1
It was chugging along well for a while, so I assume it successfully installed some of the libraries and broke on one. Any ideas what's going wrong?

The "Linked" question here Error installing Python Image Library using pip on Mac OS X 10.9 answers this issue (the top up-voted answer). Basically PIL doesn't install freetype headers properly any more. You need to link the new location to /usr/include/freetype.

fterrors.h
file was missed in your path. You can explicitely download and place this file in the appropriate directory.

You might need to install freetype.
brew install freetype

Related

got error when installing spacy

I got error when installing spacy with pip (under mac python3). Following is the last part of the error report. It seams that there are much error. How can i fix it? I have installed gcc.
gcc: warning: x86_64 conflicts with i386 (arch flags ignored)
cc1plus: warning: command line option '-Wno-strict-prototypes' is valid for C/ObjC but not for C++
g++-4.2 -bundle -undefined dynamic_lookup -arch i386 -arch x86_64 -g build/temp.macosx-10.6-intel-3.6/thinc/linalg.o -o build/lib.macosx-10.6-intel-3.6/thinc/linalg.cpython-36m-darwin.so
unable to execute 'g++-4.2': No such file or directory
error: command 'g++-4.2' failed with exit status 1
.......
/usr/local/bin/gcc -fno-strict-aliasing -Wsign-compare -fno-common -dynamic -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -arch i386 -arch x86_64 -g -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -I/private/var/folders/md/8kgtqqz12j94hbcvhqz0w7gw0000gp/T/pip-build-sm84mnwa/murmurhash/murmurhash/include -I/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -c murmurhash/mrmr.cpp -o build/temp.macosx-10.6-intel-3.6/murmurhash/mrmr.o -O3 -Wno-strict-prototypes -Wno-unused-function
gcc: warning: x86_64 conflicts with i386 (arch flags ignored)
gcc: error: murmurhash/mrmr.cpp: No such file or directory
gcc: fatal error: no input files
compilation terminated.
error: command '/usr/local/bin/gcc' failed with exit status 1
----------------------------------------
Command
"/Library/Frameworks/Python.framework/Versions/3.6/bin/python3.6 -u -c
"import setuptools,
tokenize;file='/private/var/folders/md/8kgtqqz12j94hbcvhqz0w7gw0000gp/T/pip-build-sm84mnwa/murmurhash/setup.py';f=getattr(tokenize,
'open', open)(file);code=f.read().replace('\r\n',
'\n');f.close();exec(compile(code, file, 'exec'))" install
--record /var/folders/md/8kgtqqz12j94hbcvhqz0w7gw0000gp/T/pip-4_7dl2wl-record/install-record.txt
--single-version-externally-managed --compile" failed with error code 1 in
/private/var/folders/md/8kgtqqz12j94hbcvhqz0w7gw0000gp/T/pip-build-sm84mnwa/murmurhash/
I'm really not sure if this is related or not but I saw a discussion this morning that said that the latest macOS upgrade (Catalina) drops support for 32-bit applications altogether. The reason I mention it is because the x86_64 conflicts with i386 could be referencing the 32-bit/64-bit problem.
Have you recently upgraded your Mac OS? And if so, maybe you need to upgrade your dependencies to 64-bit equivalents?

How to install PyGreSQL using Virtualenv on Mac OS Sierra

I'm configuring a virtualenv to work with a legacy webservices application developed on python using flask microframework and PostgreSQLdatabase, this application use PyGreSQL 5.0.3 as a dependency to connect with the database.
I have installed the PostgreSQL 9.6.1, i installed it using:
brew install postgresql
I have installed and working with Python 2.7
When i run the
pip install -r requirements.txt
i'm gettin this error message:
Running setup.py install for PyGreSQL ... error
Complete output from command /Users/user/Development/Projects/flask/ws/myenv/bin/python -u -c "import setuptools, tokenize;__file__='/private/var/folders/t1/x7lrbmyd3lq0k8ngknwg1zx00000gn/T/pip-build-KjQgiU/PyGreSQL/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /var/folders/t1/x7lrbmyd3lq0k8ngknwg1zx00000gn/T/pip-3lBp1N-record/install-record.txt --single-version-externally-managed --compile --install-headers /Users/user/Development/Projects/flask/ws/myenv/include/site/python2.7/PyGreSQL:
running install
running build
running build_py
creating build
creating build/lib.macosx-10.12-intel-2.7
copying pg.py -> build/lib.macosx-10.12-intel-2.7
copying pgdb.py -> build/lib.macosx-10.12-intel-2.7
running build_ext
building '_pg' extension
creating build/temp.macosx-10.12-intel-2.7
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DPYGRESQL_VERSION=5.0.3 -DDIRECT_ACCESS -DLARGE_OBJECTS -DDEFAULT_VARS -DESCAPING_FUNCS -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -I/usr/local/Cellar/postgresql/9.6.1/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c pgmodule.c -o build/temp.macosx-10.12-intel-2.7/pgmodule.o -O2 -funsigned-char -Wall -Werror
pgmodule.c:4143:9: error: implicit conversion loses integer precision: 'long' to 'int' [-Werror,-Wshorten-64-to-32]
num = PyInt_AsLong(param);
~ ^~~~~~~~~~~~~~~~~~~
pgmodule.c:4448:12: error: implicit conversion loses integer precision: 'long' to 'int' [-Werror,-Wshorten-64-to-32]
pgport = PyInt_AsLong(pg_default_port);
~ ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated.
error: command 'cc' failed with exit status 1
----------------------------------------
As you can see, this error is derived from compile and build the package, but I have the postgresql library installed, which I see as the common problem in other cases. On the other hand I have installed the command line tools of mac, i changed my compiler from cc to gcc and i'm having the same error
Any idea how to solve it, thank you in advance
I wasn't able to install any version of this package normally. It's probably a problem with the package.
Workaround: If you turn off warn-as-error, it should compile fine.
export CFLAGS="-Wno-error"
pip install PyGreSQL

install pyaudio with macOs Sierra

I upgraded my Mac to macOS Sierra and I had to start a new account. Right now I am trying to establish my environment. I ran into a problem installing pyaudio. The procedure I used is first use homebrew and install port audio.
brew install portaudio
It installs with no errors.
I proceed to install pyaudio using pip
pip install pyaudio
I receive the following error message.
cc -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch x86_64 -arch i386 -pipe -DMACOSX=1 -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/_portaudiomodule.c -o build/temp.macosx-10.12-intel-2.7/src/_portaudiomodule.o
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
portaudio.h is available in /usr/local/Cellar/portaudio/19.20140130/include
I am unfamiliar with pip and don't know how to pass the path to the complier.
Any help will be greatly appreciated.
thanks
Rod
Thanks for the suggestion. I tried it but it did not work.
It seems pip is not finding both include files and libraries when attempting to install in macOS Sierra
I did some digging into how to pass paths with pip and I successfully installed pyaudio using the following command.
sudo python3 -B -u -m pip -v install --no-warn-script-location --no-cache-dir --global-option=build_ext --global-option="-I$(brew --prefix portaudio)/include" --global-option="-L$(brew --prefix portaudio)/lib" pyaudio
Please try the command below.
sudo CPATH="$CPATH:/usr/local/include" LIBRARY_PATH="$LIBRARY_PATH:/usr/local/lib" pip install pyaudio
You can add the directory to your CPATH. Try:
CPATH="$CPATH:/usr/local/Cellar/portaudio/19.20140130/include"
pip install pyaudio

Error when trying to install pyamg: clang: error: no such file or directory: '“-I/.../boost_1_59_0”'

I am trying to install pyamg in my virtual environment. However, I am getting the following error. I am using mac OS.
c++: pyamg/amg_core/amg_core_wrap.cxx
clang: error: no such file or directory: '“-I/Users/mas/PycharmProjects/kaggle-ndsb/boost_1_59_0”'
clang: error: no such file or directory: '“-I/Users/mas/PycharmProjects/kaggle-ndsb/boost_1_59_0”'
error: Command "c++ -fno-strict-aliasing -fno-common -dynamic -arch x86_64 -arch i386 -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE “-I/Users/mas/PycharmProjects/kaggle-ndsb/boost_1_59_0” -arch x86_64 -arch i386 -pipe -D__STDC_FORMAT_MACROS=1 -I/Users/mas/PycharmProjects/Whale/Zahraa5/lib/python2.7/site-packages/numpy/core/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c pyamg/amg_core/amg_core_wrap.cxx -o build/temp.macosx-10.10-intel-2.7/pyamg/amg_core/amg_core_wrap.o" failed with exit status 1
Use Anaconda or Miniconda
conda install pyamg
takes only a few seconds.
You can create an environment with:
conda create --name my_env python=2.7
Change into it:
source activate my_env
and install pyamg:
conda install pyamg
You can still use pip to install packages conda cannot find.
Life is too short to spent time on compilation issues. ;)
I'm pretty sure that the -I at the beginning of the paths is what's screwing everything up. I bet if you tried adding those export statements back to .bashrc but took out the -I and -L prefixes then your original command would start working.
Perhaps you had those there for a reason, I've never seen that, but removing those prefixes would probably work.
Actually, I think #oarfish called it correctly in the comments. The problem seems to be the funny “ and ” characters in those paths, which are distinct from the usual " double quote symbol.
The following reproduces the error for me:
~$ CPPFLAGS=“-I/Users/mas/PycharmProjects/kaggle-ndsb/boost_1_59_0” \
LIBS=“-L/Users/mas/PycharmProjects/kaggle-ndsb/boost_1_59_0/stage/lib” \
pip install pyamg
Collecting pyamg
Downloading pyamg-3.0.1.tar.gz (759kB)
100% |████████████████████████████████| 761kB 33.2MB/s
Installing collected packages: pyamg
Running setup.py install for pyamg
...
creating build/temp.linux-x86_64-2.7
creating build/temp.linux-x86_64-2.7/pyamg
creating build/temp.linux-x86_64-2.7/pyamg/amg_core
compile options: '-D__STDC_FORMAT_MACROS=1 -I/home/alistair/.venvs/pyamg/local/lib/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c'
c++: pyamg/amg_core/amg_core_wrap.cxx
g++: error: “-I/Users/mas/PycharmProjects/kaggle-ndsb/boost_1_59_0”: No such file or directory
g++: error: “-I/Users/mas/PycharmProjects/kaggle-ndsb/boost_1_59_0”: No such file or directory
error: Command "c++ -pthread -DNDEBUG -g -fwrapv -O2 -Wall -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security “-I/Users/mas/PycharmProjects/kaggle-ndsb/boost_1_59_0” -fPIC -D__STDC_FO
RMAT_MACROS=1 -I/home/alistair/.venvs/pyamg/local/lib/python2.7/site-packages/numpy/core/include -I/usr/include/python2.7 -c pyamg/amg_core/amg_core_wrap.cxx -o build/temp.linux-x86_64-2.7/pyamg/amg_core/amg_core_wrap.o" failed with exit
status 1
----------------------------------------
Command "/home/alistair/.venvs/pyamg/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip-build-Cl5_2g/pyamg/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" insta
ll --record /tmp/pip-kkjcoa-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/alistair/.venvs/pyamg/include/site/python2.7/pyamg" failed with error code 1 in /tmp/pip-build-Cl5_2g/pyamg
Whereas with " symbols the installation succeeds:
~$ CPPFLAGS="-I/Users/mas/PycharmProjects/kaggle-ndsb/boost_1_59_0" \
LIBS="-L/Users/mas/PycharmProjects/kaggle-ndsb/boost_1_59_0/stage/lib" \
pip install pyamg
Collecting pyamg
Using cached pyamg-3.0.1.tar.gz
Installing collected packages: pyamg
Running setup.py install for pyamg
Successfully installed pyamg-3.0.1
The paths themselves are irrelevant - the compilation succeeds in spite of the fact that those directories don't actually exist on my machine.

Installing Pillow, getting -Wunused-command-line-argument-hard-error-in-future

I cannot get pillow installed.
(env)noah:cupalensic2 broinjc$ which cc
/usr/bin/cc
(env)noah:cupalensic2 broinjc$ cc --version
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix
I ran pip install mezzanine and when it got to satisfying pillow it screwed up...
cc -fno-strict-aliasing -fno-common -dynamic -g -Os -pipe -fno-common -fno-strict-aliasing -fwrapv -mno-fused-madd -DENABLE_DTRACE -DMACOSX -DNDEBUG -Wall -Wstrict-prototypes -Wshorten-64-to-32 -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -pipe -arch x86_64 -DHAVE_LIBZ -I/System/Library/Frameworks/Tcl.framework/Versions/8.5/Headers -I/System/Library/Frameworks/Tk.framework/Versions/8.5/Headers -I/opt/X11/include/freetype2 -I/Users/broinjc/cupalensic2/env/build/pillow/libImaging -I/Users/broinjc/cupalensic2/env/include -I/usr/local/include -I/opt/X11/include -I/usr/include -I/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c _imaging.c -o build/temp.macosx-10.9-intel-2.7/_imaging.o
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
----------------------------------------
Cleaning up...
Command /Users/broinjc/cupalensic2/env/bin/python -c "import setuptools;__file__='/Users/broinjc/cupalensic2/env/build/pillow/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /var/folders/lg/y_cwnrnd3rn4x_j1sbd1mg_h0000gn/T/pip-o0HQHe-record/install-record.txt --single-version-externally-managed --install-headers /Users/broinjc/cupalensic2/env/include/site/python2.7 failed with error code 1 in /Users/broinjc/cupalensic2/env/build/pillow
Storing complete log in /Users/broinjc/.pip/pip.log
Any idea what might be going on here?
This is a known issue with OSX and recent Xcode upgrade.
Instructions how to avoid the issue are here:
Ansible Installation -clang: error: unknown argument: '-mno-fused-madd'
This should do the trick::
ARCHFLAGS=-Wno-error=unused-command-line-argument-hard-error-in-future pip install Pillow

Categories