在ubuntu上安装CartoDB 16.04 gdal编译错误

时间:2018-01-10 04:05:24

标签: python linux ubuntu gdal cartodb

我按照安装步骤进行操作 https://gist.github.com/azvoleff/f8f06d22a8a4d89401e09d6607a5ecc4

将cartoDB安装到Ubuntu 16.04。

一切都很好并且安装正确(虽然我使用RVM而不是获取ruby的源代码并按照步骤中的建议自行编译)。

但在运行时: pip install --no-use-wheel -r python_requirements.txt

有一个错误,关于gdal说,但它与步骤中提到的错误不同。

DEPRECATION: --no-use-wheel is deprecated and will be removed in the future.  Please use --no-binary :all: instead.
Requirement already satisfied: chardet==2.3.0 in /usr/local/lib/python2.7/dist-packages (from -r python_requirements.txt (line 1))
Requirement already satisfied: argparse==1.2.1 in /usr/lib/python2.7 (from -r python_requirements.txt (line 2))
Requirement already satisfied: brewery==0.6 in /usr/local/lib/python2.7/dist-packages (from -r python_requirements.txt (line 3))
Requirement already satisfied: redis==2.4.9 in /usr/local/lib/python2.7/dist-packages (from -r python_requirements.txt (line 4))
Requirement already satisfied: python-varnish==0.1.2 in /usr/local/lib/python2.7/dist-packages (from -r python_requirements.txt (line 5))
Collecting gdal==1.10.0 (from -r python_requirements.txt (line 6))
  Using cached GDAL-1.10.0.tar.gz
Collecting csvkit==0.9.0 (from -r python_requirements.txt (line 7))
  Using cached csvkit-0.9.0.tar.gz
Collecting openpyxl==2.1.3 (from -r python_requirements.txt (line 8))
  Using cached openpyxl-2.1.3.tar.gz
Collecting xlrd>=0.7.1 (from csvkit==0.9.0->-r python_requirements.txt (line 7))
  Using cached xlrd-1.1.0.tar.gz
Collecting sqlalchemy>=0.6.6 (from csvkit==0.9.0->-r python_requirements.txt (line 7))
  Using cached SQLAlchemy-1.2.0.tar.gz
Collecting six>=1.6.1 (from csvkit==0.9.0->-r python_requirements.txt (line 7))
  Using cached six-1.11.0.tar.gz
Collecting python-dateutil==2.2 (from csvkit==0.9.0->-r python_requirements.txt (line 7))
  Using cached python-dateutil-2.2.tar.gz
Collecting dbf==0.94.003 (from csvkit==0.9.0->-r python_requirements.txt (line 7))
  Using cached dbf-0.94.003.tar.gz
Collecting jdcal (from openpyxl==2.1.3->-r python_requirements.txt (line 8))
  Using cached jdcal-1.3.tar.gz
Skipping bdist_wheel for gdal, due to binaries being disabled for it.
Skipping bdist_wheel for csvkit, due to binaries being disabled for it.
Skipping bdist_wheel for openpyxl, due to binaries being disabled for it.
Skipping bdist_wheel for xlrd, due to binaries being disabled for it.
Skipping bdist_wheel for sqlalchemy, due to binaries being disabled for it.
Skipping bdist_wheel for six, due to binaries being disabled for it.
Skipping bdist_wheel for python-dateutil, due to binaries being disabled for it.
Skipping bdist_wheel for dbf, due to binaries being disabled for it.
Skipping bdist_wheel for jdcal, due to binaries being disabled for it.
Installing collected packages: gdal, xlrd, sqlalchemy, jdcal, openpyxl, six, python-dateutil, dbf, csvkit
  Found existing installation: GDAL 2.2.0
    Uninstalling GDAL-2.2.0:
      Successfully uninstalled GDAL-2.2.0
  Running setup.py install for gdal ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-U2YlBY/gdal/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-UB4Lg0-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-x86_64-2.7
    copying gdal.py -> build/lib.linux-x86_64-2.7
    copying ogr.py -> build/lib.linux-x86_64-2.7
    copying osr.py -> build/lib.linux-x86_64-2.7
    copying gdalconst.py -> build/lib.linux-x86_64-2.7
    creating build/lib.linux-x86_64-2.7/osgeo
    copying osgeo/gdalconst.py -> build/lib.linux-x86_64-2.7/osgeo
    copying osgeo/gdal_array.py -> build/lib.linux-x86_64-2.7/osgeo
    copying osgeo/gdalnumeric.py -> build/lib.linux-x86_64-2.7/osgeo
    copying osgeo/osr.py -> build/lib.linux-x86_64-2.7/osgeo
    copying osgeo/__init__.py -> build/lib.linux-x86_64-2.7/osgeo
    copying osgeo/ogr.py -> build/lib.linux-x86_64-2.7/osgeo
    copying osgeo/gdal.py -> build/lib.linux-x86_64-2.7/osgeo
    running build_ext
    building 'osgeo._gdal' extension
    creating build/temp.linux-x86_64-2.7
    creating build/temp.linux-x86_64-2.7/extensions
    x86_64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fno-strict-aliasing -Wdate-time -D_FORTIFY_SOURCE=2 -g -fstack-protector-strong -Wformat -Werror=format-security -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I/usr/include/python2.7 -I. -I/usr/include -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-2.7/extensions/gdal_wrap.o
    cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    extensions/gdal_wrap.cpp:2853:22: fatal error: cpl_port.h: No such file or directory
    compilation terminated.
    error: command 'x86_64-linux-gnu-gcc' failed with exit status 1

    ----------------------------------------
  Rolling back uninstall of GDAL
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-U2YlBY/gdal/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-UB4Lg0-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-U2YlBY/gdal/

我是ubuntu的新手,之前我曾尝试将其设置为centos(因为我对centos更为熟悉),但它比使用ubuntu更糟糕,因为许多依赖项缺失/过时

有没有人建议如何在ubuntu /任何其他基于Linux的机器上成功设置cartoDB? (或者我应该怎么处理这个编译错误?)

我想我应该得到gdal版本1.10.0?但是如何在ubuntu中做到这一点...

[UPDATE-1]

也许是因为从这个错误中找不到cpl_port.h extensions/gdal_wrap.cpp:2853:22: fatal error: cpl_port.h: No such file or directory

所以,我按照Oz123建议安装了libgdal-dev。

apt-get install libgdal-dev
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libgdal-dev is already the newest version (2.2.2+dfsg-1~xenial1).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

我的GDAL版本是

gdalinfo --version
GDAL 2.2.2, released 2017/09/15
遗憾的是,错误仍然是一样的。 我仍然试图找出如何编译/更改已安装的GDAL版本到1.10.0因为我假设要求是GDAL 1.10.0而我所拥有的是2.2.2,这就是为什么它试图再次编译,我对此是否正确?

...
Collecting gdal==1.10.0 (from -r python_requirements.txt (line 6))
Using cached GDAL-1.10.0.tar.gz
...
Installing collected packages: gdal, xlrd, sqlalchemy, jdcal, openpyxl, six, python-dateutil, dbf, csvkit
Found existing installation: GDAL 2.2.0
Uninstalling GDAL-2.2.0:
  Successfully uninstalled GDAL-2.2.0
Running setup.py install for gdal ... error
...

[针对此特定问题的更新 - 答案]

thx to Oz123,我执行:

export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal

并重试编译,它修复了这个cpl_port.h问题。但安装仍然在同一安装步骤(GDAL编译)失败,但我想我应该在不同的线程中问这个以保持这个堆栈清洁。

1 个答案:

答案 0 :(得分:0)

这可能是因为您遗漏了libgdal-devfound through ubuntu package content search)。

如果您安装了具有硬编码C依赖性的软件包,则应确保具有构建依赖性。

  

我想我应该得到gdal版本1.10.0?但是如何做到这一点   的ubuntu ...

如果您按照此步骤操作:

sudo add-apt-repository ppa:ubuntugis/ppa
sudo apt-get update

您将获得更高版本的GDAL。

从不如此,您应该使用libgdal-dev安装构建依赖项sudo apt-get install libgdal-dev,重复pip install --no-use-wheel -r python_requirements.txt,如果您收到更多错误,请在ubuntu软件包中查找缺少的头文件内容搜索页面,安装包并重复直到完成。

您还应该将路径传递给pip:

export CPLUS_INCLUDE_PATH=/usr/include/gdal

export C_INCLUDE_PATH=/usr/include/gdal

pip install --no-use-wheel -r python_requirements.txt