Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Mac OS X,pip:为包含C库的包指定编译器_Python_C_Osx Lion_Pip_Pypi - Fatal编程技术网

Python Mac OS X,pip:为包含C库的包指定编译器

Python Mac OS X,pip:为包含C库的包指定编译器,python,c,osx-lion,pip,pypi,Python,C,Osx Lion,Pip,Pypi,我在用默认的clang编译器使用pip编译mapscript(是pypi中包含C代码的包)时遇到了一些问题 以下是我的尝试:- $ sudo pip install mapscript Password: Downloading/unpacking mapscript Running setup.py egg_info for package mapscript Requirement already satisfied (use --upgrade to upgrade): distri

我在用默认的clang编译器使用pip编译mapscript(是pypi中包含C代码的包)时遇到了一些问题

以下是我的尝试:-

$ sudo pip install mapscript
Password:
Downloading/unpacking mapscript
  Running setup.py egg_info for package mapscript

Requirement already satisfied (use --upgrade to upgrade): distribute in /opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages (from mapscript)
Installing collected packages: mapscript
  Running setup.py install for mapscript

    building '_mapscript' extension
    /opt/local/bin/gcc-apple-4.2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -I/opt/local/include -I/opt/local/include -I/opt/local/include -pipe -O2 -arch x86_64 -fPIC -Wall -DNEED_NONBLOCKING_STDERR -DHAVE_VSNPRINTF -DNEED_STRRSTR -DNEED_NONBLOCKING_STDERR -DUSE_WMS_SVR -DUSE_GDAL -DUSE_OGR -DUSE_PROJ -DUSE_EPPL -DUSE_GD_GIF -DUSE_GD_PNG -DUSE_GD_JPEG -DUSE_GD_WBMP -DUSE_GD_FT -DGD_HAS_FTEX_XSHOW -DGD_HAS_GDIMAGEGIFPTR -DGD_HAS_GETBITMAPFONTS -DUSE_ICONV -DUSE_ZLIB -I/opt/local/include -I/opt/local/include -I/opt/local/include -DHAVE_VSNPRINTF -DNEED_STRRSTR -DNEED_NONBLOCKING_STDERR -DUSE_WMS_SVR -DUSE_GDAL -DUSE_OGR -DUSE_PROJ -DUSE_EPPL -DUSE_GD_GIF -DUSE_GD_PNG -DUSE_GD_JPEG -DUSE_GD_WBMP -DUSE_GD_FT -DGD_HAS_FTEX_XSHOW -DGD_HAS_GDIMAGEGIFPTR -DGD_HAS_GETBITMAPFONTS -DUSE_ICONV -DUSE_ZLIB -DHAVE_VSNPRINTF -DNEED_STRRSTR -DNEED_NONBLOCKING_STDERR -DUSE_WMS_SVR -DUSE_GDAL -DUSE_OGR -DUSE_PROJ -DUSE_EPPL -DUSE_GD_GIF -DUSE_GD_PNG -DUSE_GD_JPEG -DUSE_GD_WBMP -DUSE_GD_FT -DGD_HAS_FTEX_XSHOW -DGD_HAS_GDIMAGEGIFPTR -DGD_HAS_GETBITMAPFONTS -DUSE_ICONV -DUSE_ZLIB -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c mapscript_wrap.c -o build/temp.macosx-10.7-x86_64-2.7/mapscript_wrap.o
    mapscript_wrap.c:2564:23: error: mapserver.h: No such file or directory
    mapscript_wrap.c:2565:25: error: maptemplate.h: No such file or directory
    mapscript_wrap.c:2566:23: error: mapogcsld.h: No such file or directory
...
mapscript_wrap.c:45472: error: 'MS_DEBUGLEVEL_VV' undeclared (first use in this function)

mapscript_wrap.c:45473: error: 'MS_DEBUGLEVEL_VVV' undeclared (first use in this function)

mapscript_wrap.c:45476: error: 'MS_GET_REQUEST' undeclared (first use in this function)

mapscript_wrap.c:45477: error: 'MS_POST_REQUEST' undeclared (first use in this function)

error: command '/opt/local/bin/gcc-apple-4.2' failed with exit status 1

----------------------------------------
Command /opt/local/Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python -c "import setuptools;__file__='/Users/calvin/build/mapscript/setup.py';exec(compile(open(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --single-version-externally-managed --record /tmp/pip-GYwtAz-record/install-record.txt failed with error code 1
Storing complete log in /Users/calvin/.pip/pip.log
gcc-apple-4.2版本为

$ gcc-apple-4.2 --version
i686-apple-darwin11-gcc-apple-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
Copyright (C) 2007 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

如何尝试使用其他编译器安装mapscript?有没有办法明确指定pip在pypi包中编译C代码时将调用的特定编译器?

设置CC环境变量似乎有效,例如:

env CC=/usr/bin/gcc-4.0 pip安装pyOpenSSL


我也有同样的问题。Lion上的Python坏了吗?您好@KyleWpppd,经过深入研究,我了解到mapscript的C扩展默认使用与我编译Python2.7(通过Macports)时使用的编译器相同的编译器进行编译。由于我使用gcc-apple-4.2通过MacPorts编译Python2.7,因此在编译mapscript时将使用相同的编译器。为了解决这个问题,我必须首先确保正确编译MapServer 6.0.1(而MapServer 6.0.1在MacPorts上不可用-MacPorts上的副本已严重过时)。此后,我使用“sudo python setup.py build”在系统范围内安装了mapscript。我在OS X 10.8.2上也遇到了同样的问题——我通过Mac HomeBrew使用--devel安装了mapserver,但pip安装mapscript失败的原因非常相似。它在任何地方都找不到mapserver.h。这既不能解决问题,也不能解决问题。这个问题清楚地表明,构建过程无法找到所需的头文件。h是第一个--Jamesmills问题是“如何尝试用另一个编译器安装mapscript?”我相信这个答案非常明确地解决了这个问题。