简体   繁体   中英

Python/Pip C package PyProj fails to compile with GCC

I'm trying to install PyProj on a WebFaction VM, via virtualenv & pip . I'm getting compile errors. I'm using this command:

$ pip install pyproj

There's a lot of output, terminating in this:

src/geodesic.c: In function ‘InverseStart’:

src/geodesic.c:1093: error: ISO C90 forbids mixed declarations and code

error: command 'gcc' failed with exit status 1

----------------------------------------
Command "/home/<user>/webapps/<webapp>/env/py34/bin/python3.4 -c "import setuptools, tokenize;__file__='/tmp/pip-build-ow1vcsjk/pyproj/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-cl2pbd20-record/install-record.txt --single-version-externally-managed --compile --install-headers /home/<user>/webapps/<webapp>/env/py34/include/site/python3.4" failed with error code 1 in /tmp/pip-build-ow1vcsjk/pyproj

I'm not quite sure where to start. I gather from this SO question the problem lies in compatibility for C90 in PyProj, and I might compile instead against C99. Just a guess.

As mentioned, this is on a remote VM with shell access. I have a matching Virtualenv on my dev machine (Mac), which compiles without issue. However, there are different compilers:

Dev:

$ gcc --version
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 6.0 (clang-600.0.56) (based on LLVM 3.5svn)

VM:

$ gcc --version
gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-11)

Ideas? Thanks in advance.

The problem is that the version of GCC on your VM is defaulting to the ISO C90 standard but the pyproj code is incompatible with that. To force GCC to use C99 instead you need to set the CFLAGS environment variable accordingly, try

export CFLAGS='-std=c99'

then run pip install pyproj again. I get the same problem with healpy and this works for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM