基于我现有的django webapp以及对docker的一些简单介绍,我已经设置了这个docker文件来处理站点设置
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /code
RUN apt-get update && apt-get install --yes libgdal-dev
RUN export CPLUS_INCLUDE_PATH=/usr/include/gdal
RUN export C_INCLUDE_PATH=/usr/include/gdal
WORKDIR /code
COPY . /code/
RUN pip install -r requirements.txt
和需求文件
Django==2.1.5
psycopg2==2.7.6.1
numpy
gdal
当我运行命令sudo docker-compose build
时,它最终因该错误而崩溃
Building wheels for collected packages: gdal
Running setup.py bdist_wheel for gdal: started
Running setup.py bdist_wheel for gdal: finished with status 'error'
Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-emkt_bai/gdal/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" bdist_wheel -d /tmp/pip-wheel-1tv4zrfw --python-tag cp37:
WARNING: numpy not available! Array support will not be enabled
...
Skipping optional fixer: ws_comma
running build_ext
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/usr/local/include/python3.7m -I. -I/usr/include -c gdal_python_cxx11_test.cpp -o gdal_python_cxx11_test.o
building 'osgeo._gdal' extension
creating build/temp.linux-x86_64-3.7
...
extensions/gdal_wrap.cpp:4073:1: error: ‘VSIDIR’ does not name a type
VSIDIR* wrapper_VSIOpenDir( const char * utf8_path,
^~~~~~
extensions/gdal_wrap.cpp:4121:38: error: ‘VSIDIR’ was not declared in this scope
DirEntry* wrapper_VSIGetNextDirEntry(VSIDIR* dir)
^~~~~~
extensions/gdal_wrap.cpp:4121:46: error: ‘dir’ was not declared in this scope
DirEntry* wrapper_VSIGetNextDirEntry(VSIDIR* dir)
^~~
extensions/gdal_wrap.cpp:3369:13: warning: ‘void ClearErrorState()’ defined but not used [-Wunused-function]
static void ClearErrorState()
^~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:3321:6: warning: ‘void DontUseExceptions()’ defined but not used [-Wunused-function]
void DontUseExceptions() {
^~~~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:3304:6: warning: ‘void UseExceptions()’ defined but not used [-Wunused-function]
void UseExceptions() {
^~~~~~~~~~~~~
extensions/gdal_wrap.cpp:3298:5: warning: ‘int GetUseExceptions()’ defined but not used [-Wunused-function]
int GetUseExceptions() {
^~~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:3243:13: warning: ‘void update_buffer_size(void*, char*, char*, size_t)’ defined but not used [-Wunused-function]
static void update_buffer_size(void* obj, char* data, char* data_aligned, size_t buf_size)
^~~~~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:3224:7: warning: ‘char* get_aligned_buffer(char*, GDALDataType)’ defined but not used [-Wunused-function]
char* get_aligned_buffer(char* data, GDALDataType ntype)
^~~~~~~~~~~~~~~~~~
error: command 'gcc' failed with exit status 1
----------------------------------------
Failed building wheel for gdal
Running setup.py clean for gdal
Failed to build gdal
Installing collected packages: pytz, Django, psycopg2, numpy, gdal
Running setup.py install for gdal: started
Running setup.py install for gdal: finished with status 'error'
Complete output from command /usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-emkt_bai/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-record-a0yj9zno/install-record.txt --single-version-externally-managed --compile:
running install
running build
running build_py
creating build
creating build/lib.linux-x86_64-3.7
copying gdal.py -> build/lib.linux-x86_64-3.7
copying ogr.py -> build/lib.linux-x86_64-3.7
copying osr.py -> build/lib.linux-x86_64-3.7
copying gdalconst.py -> build/lib.linux-x86_64-3.7
copying gdalnumeric.py -> build/lib.linux-x86_64-3.7
creating build/lib.linux-x86_64-3.7/osgeo
copying osgeo/ogr.py -> build/lib.linux-x86_64-3.7/osgeo
copying osgeo/gdal_array.py -> build/lib.linux-x86_64-3.7/osgeo
copying osgeo/gdalconst.py -> build/lib.linux-x86_64-3.7/osgeo
copying osgeo/gnm.py -> build/lib.linux-x86_64-3.7/osgeo
copying osgeo/gdal.py -> build/lib.linux-x86_64-3.7/osgeo
copying osgeo/osr.py -> build/lib.linux-x86_64-3.7/osgeo
copying osgeo/__init__.py -> build/lib.linux-x86_64-3.7/osgeo
copying osgeo/gdalnumeric.py -> build/lib.linux-x86_64-3.7/osgeo
Fixing build/lib.linux-x86_64-3.7/gdal.py build/lib.linux-x86_64-3.7/ogr.py build/lib.linux-x86_64-3.7/osr.py build/lib.linux-x86_64-3.7/gdalconst.py build/lib.linux-x86_64-3.7/gdalnumeric.py build/lib.linux-x86_64-3.7/osgeo/ogr.py build/lib.linux-x86_64-3.7/osgeo/gdal_array.py build/lib.linux-x86_64-3.7/osgeo/gdalconst.py build/lib.linux-x86_64-3.7/osgeo/gnm.py build/lib.linux-x86_64-3.7/osgeo/gdal.py build/lib.linux-x86_64-3.7/osgeo/osr.py build/lib.linux-x86_64-3.7/osgeo/__init__.py build/lib.linux-x86_64-3.7/osgeo/gdalnumeric.py
Skipping optional fixer: ws_comma
Fixing build/lib.linux-x86_64-3.7/gdal.py build/lib.linux-x86_64-3.7/ogr.py build/lib.linux-x86_64-3.7/osr.py build/lib.linux-x86_64-3.7/gdalconst.py build/lib.linux-x86_64-3.7/gdalnumeric.py build/lib.linux-x86_64-3.7/osgeo/ogr.py build/lib.linux-x86_64-3.7/osgeo/gdal_array.py build/lib.linux-x86_64-3.7/osgeo/gdalconst.py build/lib.linux-x86_64-3.7/osgeo/gnm.py build/lib.linux-x86_64-3.7/osgeo/gdal.py build/lib.linux-x86_64-3.7/osgeo/osr.py build/lib.linux-x86_64-3.7/osgeo/__init__.py build/lib.linux-x86_64-3.7/osgeo/gdalnumeric.py
Skipping optional fixer: ws_comma
running build_ext
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/usr/local/include/python3.7m -I/usr/local/lib/python3.7/site-packages/numpy/core/include -I/usr/include -c gdal_python_cxx11_test.cpp -o gdal_python_cxx11_test.o
building 'osgeo._gdal' extension
creating build/temp.linux-x86_64-3.7
creating build/temp.linux-x86_64-3.7/extensions
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I../../port -I../../gcore -I../../alg -I../../ogr/ -I../../ogr/ogrsf_frmts -I../../gnm -I../../apps -I/usr/local/include/python3.7m -I/usr/local/lib/python3.7/site-packages/numpy/core/include -I/usr/include -c extensions/gdal_wrap.cpp -o build/temp.linux-x86_64-3.7/extensions/gdal_wrap.o -I/usr/include/gdal
extensions/gdal_wrap.cpp:4073:1: error: ‘VSIDIR’ does not name a type
VSIDIR* wrapper_VSIOpenDir( const char * utf8_path,
^~~~~~
extensions/gdal_wrap.cpp:4121:38: error: ‘VSIDIR’ was not declared in this scope
DirEntry* wrapper_VSIGetNextDirEntry(VSIDIR* dir)
^~~~~~
extensions/gdal_wrap.cpp:4121:46: error: ‘dir’ was not declared in this scope
DirEntry* wrapper_VSIGetNextDirEntry(VSIDIR* dir)
^~~
extensions/gdal_wrap.cpp:3369:13: warning: ‘void ClearErrorState()’ defined but not used [-Wunused-function]
static void ClearErrorState()
^~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:3321:6: warning: ‘void DontUseExceptions()’ defined but not used [-Wunused-function]
void DontUseExceptions() {
^~~~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:3304:6: warning: ‘void UseExceptions()’ defined but not used [-Wunused-function]
void UseExceptions() {
^~~~~~~~~~~~~
extensions/gdal_wrap.cpp:3298:5: warning: ‘int GetUseExceptions()’ defined but not used [-Wunused-function]
int GetUseExceptions() {
^~~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:3243:13: warning: ‘void update_buffer_size(void*, char*, char*, size_t)’ defined but not used [-Wunused-function]
static void update_buffer_size(void* obj, char* data, char* data_aligned, size_t buf_size)
^~~~~~~~~~~~~~~~~~
extensions/gdal_wrap.cpp:3224:7: warning: ‘char* get_aligned_buffer(char*, GDALDataType)’ defined but not used [-Wunused-function]
char* get_aligned_buffer(char* data, GDALDataType ntype)
^~~~~~~~~~~~~~~~~~
error: command 'gcc' failed with exit status 1
----------------------------------------
Command "/usr/local/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-install-emkt_bai/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-record-a0yj9zno/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-install-emkt_bai/gdal/
我根据另一个堆栈用户给出的答案添加了gdal回购,但是当它传递先前的错误时,它抛出了这个新错误。