How to build Python with Clang on Mac OS X Mavericks - python

How can I build Python with Clang on Mac OS X? Mavericks already comes with Python 2.7 installed. The reason I'm asking is because I am having issues trying to install PyLucene and it's possibly because Python was compiled with something other than Clang, while JCC as part of PyLucene needs to be compiled with Clang.

i see your problem now. when building jcc,
clang++ -Wl,-x -dynamiclib -undefined dynamic_lookup build/temp.macosx-10.9-x86_64-2.7/jcc/sources/jcc.o build/temp.macosx-10.9-x86_64-2.7/jcc/sources/JCCEnv.o -o build/lib.macosx-10.9-x86_64-2.7/libjcc.dylib -L/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/lib -ljava -L/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/lib/server -ljvm -Wl,-rpath -Wl,/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/lib -Wl,-rpath -Wl,/Library/Java/JavaVirtualMachines/jdk1.7.0_40.jdk/Contents/Home/jre/lib/server -Wl,-S -install_name #rpath/libjcc.dylib -current_version 2.21 -compatibility_version 2.21
ld: internal error: atom not found in symbolIndex(__ZN7JNIEnv_13CallIntMethodEP8_jobjectP10_jmethodIDz) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'clang++' failed with exit status 1
actually this is a known issue, and the solution is here
-x link flag causing link errors on Mac OSX 10.9 (bug?)
just run the above clang++ command without the "-x" in the same directory. and then run the "python setup.py build" again...

Related

Problem installing qutip on Mac Catalina 10.15.6: "could not build wheels for qutip which use PEP 517"

I am trying to install qutip on a Mac (Catalina 10.15.6). I am using:
Python 3.8.3
Anaconda 4.8.4
I create a virtual environment with the command conda create -n qutip python=3.8 anaconda. Here's the error message:
g++ -bundle -undefined dynamic_lookup -
L/usr/local/anaconda3/envs/qutip/lib -arch x86_64 -L/usr/local/anaconda3/envs/qutip/lib -arch x86_64 /usr/local/opt/readline/include -arch x86_64 build/temp.macosx-10.9-x86_64-3.7/qutip/cy/spmatfuncs.o build/temp.macosx-10.9-x86_64-3.7/qutip/cy/src/zspmv.o -o build/lib.macosx-10.9-x86_64-3.7/qutip/cy/spmatfuncs.cpython-37m-darwin.so -mmacosx-version-min=10.9
ld: can't map file, errno=22 file '/usr/local/opt/readline/include' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'g++' failed with exit status 1
----------------------------------------
ERROR: Failed building wheel for qutip
Failed to build qutip
ERROR: Could not build wheels for qutip which use PEP 517 and cannot be installed directly
I looked around and I don't see anything recent for this. I tried to install qutip from source and I got the same error. Does anyone have any thoughts? Thank you.

Installing python-igraph with pip on Mac 10.14 fails with "library not found for -lstdc++"

I am trying to install python-igraph using pip3 on Mac OS X 10.14, but the installation fails with the following error message:
$ pip3 install python-igraph
...snip...
gcc -bundle -undefined dynamic_lookup -L/Users/charles/.pyenv/versions/miniconda3-4.3.30/lib -arch x86_64 -L/Users/charles/.pyenv/versions/miniconda3-4.3.30/lib -arch x86_64 -arch x86_64 build/temp.macosx-10.7-x86_64-3.6/src/edgeobject.o build/temp.macosx-10.7-x86_64-3.6/src/common.o build/temp.macosx-10.7-x86_64-3.6/src/py2compat.o build/temp.macosx-10.7-x86_64-3.6/src/graphobject.o build/temp.macosx-10.7-x86_64-3.6/src/indexing.o build/temp.macosx-10.7-x86_64-3.6/src/igraphmodule.o build/temp.macosx-10.7-x86_64-3.6/src/bfsiter.o build/temp.macosx-10.7-x86_64-3.6/src/convert.o build/temp.macosx-10.7-x86_64-3.6/src/vertexobject.o build/temp.macosx-10.7-x86_64-3.6/src/random.o build/temp.macosx-10.7-x86_64-3.6/src/edgeseqobject.o build/temp.macosx-10.7-x86_64-3.6/src/error.o build/temp.macosx-10.7-x86_64-3.6/src/vertexseqobject.o build/temp.macosx-10.7-x86_64-3.6/src/arpackobject.o build/temp.macosx-10.7-x86_64-3.6/src/attributes.o build/temp.macosx-10.7-x86_64-3.6/src/filehandle.o build/temp.macosx-10.7-x86_64-3.6/src/pyhelpers.o igraphcore/lib/libigraph.a -Ligraphcore/lib -L/usr/local/lib -L/usr/lib -lxml2 -lz -lm -lstdc++ -o build/lib.macosx-10.7-x86_64-3.6/igraph/_igraph.cpython-36m-darwin.so
clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of OS X 10.9 [-Wdeprecated]
ld: library not found for -lstdc++
clang: error: linker command failed with exit code 1 (use -v to see invocation)
error: command 'gcc' failed with exit status 1
gcc version:
$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin18.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
python version:
$ python3 --version
Python 3.6.7
(Side note, python and python3 point to the same python, and pip and pip3 point to the same (corresponding) pip.)
I also tried running xcode-select --install but this told me 'command line tools are already installed, use "Software Update" to install updates' (Xcode is up to date).
Run
export MACOSX_DEPLOYMENT_TARGET=10.9
before running pip install python-igraph. Then you should see it install successfully:
$ pip install python-igraph
Collecting python-igraph
Using cached https://files.pythonhosted.org/packages/0f/a0/4e7134f803737aa6eebb4e5250565ace0e2599659e22be7f7eba520ff017/python-igraph-0.7.1.post6.tar.gz
Building wheels for collected packages: python-igraph
Running setup.py bdist_wheel for python-igraph ... done
Stored in directory: /Users/charles/Library/Caches/pip/wheels/41/d6/02/34eebae97e25f5b87d60f4c0687e00523e3f244fa41bc3f4a7
Successfully built python-igraph
Installing collected packages: python-igraph
Successfully installed python-igraph-0.7.1.post6

How to install psycopg2-2.6 with python2.6

my linux server: 2.6.18 RHEL5
gcc version: gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-51)
installed rpm packages:
python26-2.6.5-4.el5
python26-devel-2.6.5-4.el5
postgresql-devel-8.1.23-1
postgresql-libs-8.1.23-1
postgresql-devel-8.1.23-1
postgresql-8.1.23-1
when I run "python2.6 setup.py install", the error message is:
gcc -pthread -shared build/temp.linux-x86_64-2.6/psycopg/psycopgmodule.o build/temp.linux-x86_64-2.6/psycopg/green.o build/temp.linux-x86_64-2.6/psycopg/pqpath.o build/temp.linux-x86_64-2.6/psycopg/utils.o build/temp.linux-x86_64-2.6/psycopg/bytes_format.o build/temp.linux-x86_64-2.6/psycopg/connection_int.o build/temp.linux-x86_64-2.6/psycopg/connection_type.o build/temp.linux-x86_64-2.6/psycopg/cursor_int.o build/temp.linux-x86_64-2.6/psycopg/cursor_type.o build/temp.linux-x86_64-2.6/psycopg/diagnostics_type.o build/temp.linux-x86_64-2.6/psycopg/error_type.o build/temp.linux-x86_64-2.6/psycopg/lobject_int.o build/temp.linux-x86_64-2.6/psycopg/lobject_type.o build/temp.linux-x86_64-2.6/psycopg/notify_type.o build/temp.linux-x86_64-2.6/psycopg/xid_type.o build/temp.linux-x86_64-2.6/psycopg/adapter_asis.o build/temp.linux-x86_64-2.6/psycopg/adapter_binary.o build/temp.linux-x86_64-2.6/psycopg/adapter_datetime.o build/temp.linux-x86_64-2.6/psycopg/adapter_list.o build/temp.linux-x86_64-2.6/psycopg/adapter_pboolean.o build/temp.linux-x86_64-2.6/psycopg/adapter_pdecimal.o build/temp.linux-x86_64-2.6/psycopg/adapter_pint.o build/temp.linux-x86_64-2.6/psycopg/adapter_pfloat.o build/temp.linux-x86_64-2.6/psycopg/adapter_qstring.o build/temp.linux-x86_64-2.6/psycopg/microprotocols.o build/temp.linux-x86_64-2.6/psycopg/microprotocols_proto.o build/temp.linux-x86_64-2.6/psycopg/typecast.o -L. -L/usr/lib64 -lpython2.6 -lpq -o build/lib.linux-x86_64-2.6/psycopg2/_psycopg.so
/usr/bin/ld: build/temp.linux-x86_64-2.6/psycopg/psycopgmodule.o: relocation R_X86_64_PC32 against `lobjectType' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: Bad value
collect2: ld return 1
error: command 'gcc' failed with exit status 1
when I use "gcc -fPIC", the result is still the same.
I know this was asked a long time ago, but I recently came across the same problem described (though on a CentOS system instead of Red Hat).
I am not sure if this will help, but my problem is the version of libpq (installed with Postgres) is "too old". The solution that worked for me was to install version 2.5 of psycopg2. This version is good enough for my needs.
I found the idea here:
https://github.com/psycopg/psycopg2/issues/305
I used version 2.5, but perhaps a slightly newer version would work as well. I found the source code here:
http://initd.org/psycopg/tarballs/PSYCOPG-2-5/

How to install pyamf to Windows Python 2.7

I tried to install pyamf to Python 2.7 x86 on Windows 7 x64.
I used pip install or python setup.py install, but they have the same error.
skipping 'cpyamf\amf0.c' Cython extension (up-to-date)
building 'cpyamf.amf0' extension
gcc -mno-cygwin -mdll -O -Wall -IC:\Python27\include -IC:\Python27\PC -c cpyamf\
amf0.c -o build\temp.win32-2.7\Release\cpyamf\amf0.o
error: command 'gcc' failed: No such file or directory
I also tried various versions. I know there is a compiled binary installer for Windows for pyamf version 6. But I'd like to use later version. How to fix this problem?

biopython installation: error: command 'gcc' failed with exit status 1

I am trying to install the python package biopython from source on my Macbook pro OSX 10.9.4,
I run python setup.py build in the terminal and receive this
running build
running build_py
running build_ext
building 'Bio.cpairwise2' extension
Compiling with an SDK that doesn't seem to exist: /Developer/SDKs/MacOSX10.6.sdk
Please check your Xcode installation
gcc -DNDEBUG -g -O3 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.6.sdk -Qunused-arguments -Qunused-arguments -I/Applications/Canopy.app/appdata/canopy-1.4.1.1975.macosx-x86_64/Canopy.app/Contents/include/python2.7 -c Bio/cpairwise2module.c -o build/temp.macosx-10.6-x86_64-2.7/Bio/cpairwise2module.o
clang: warning: no such sysroot directory: '/Developer/SDKs/MacOSX10.6.sdk'
In file included from Bio/cpairwise2module.c:12:
/Applications/Canopy.app/appdata/canopy-1.4.1.1975.macosx- x86_64/Canopy.app/Contents/include/python2.7/Python.h:33:10: fatal error:
'stdio.h' file not found
#include <stdio.h>
^
1 error generated.
error: command 'gcc' failed with exit status 1
I checked that Xcode should be properly installed and working
You should be using pip. Try:
pip install biopython
Uninstalled Canopy and everything worked like a charm...
Try installing the Biopython version available from the Canopy "Package Manager" > "Available Packages" > "Canopy Packages".
This way, I seem to have solved a similar problem while installing Pyensembl, that also installs Biopython.

Categories

Resources