无法在win7上导入名称GDALRaster

时间:2017-05-23 16:32:58

标签: python windows installation gdal

我正在尝试建立一个GIS项目,但每次都出现错误

django.core.exceptions.ImproperlyConfigured: 
'django.contrib.gis.db.backends.postgis' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'postgresql', 'sqlite3'
Error was: cannot import name GDALRaster 

我试图修复它购买纠正环境变量 比如this问题

set OSGEO4W_ROOT=C:\OSGeo4W64
set PYTHON_ROOT=C:\Python27
set GDAL_DATA=%OSGEO4W_ROOT%\share\gdal
set PROJ_LIB=%OSGEO4W_ROOT%\share\proj
set PATH=%PATH%;%PYTHON_ROOT%;%OSGEO4W_ROOT%\bin
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"     /v Path /t REG_EXPAND_SZ /f /d "%PATH%" 
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment"     /v GDAL_DATA /t REG_EXPAND_SZ /f /d "%GDAL_DATA%"
reg ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /v PROJ_LIB /t REG_EXPAND_SZ /f /d "%PROJ_LIB%"

通过创建virtualenv enter image description here

安装OSGeo4W64

将所有内容添加到

 GDAL_LIBRARY_PATH
 c:\Python27\Lib\site-packages\django\contrib\gis\gdal\;C:\Python27\Lib\site-packages\django\contrib\gis\GDALRaster\raster;C:\OSGeo4W64\bin;C:\OSGeo4W64\lib;C:\Program Files\PostgreSQL\9.6\bin;C:\Program Files\PostgreSQL\9.6\include;C:\Programing\python\django\vdozor\Lib\site-packages\django\contrib\gis\gdal;C:\Programing\python\django\vdozor\Lib\site-packages;C:\Programing\python\django\vdozor\Lib\site-packages\osgeo\lib

我的settings.py

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '$@1&()4xa_7rbsi-t5j1x9e0#o&0zjjhh7n(wn&*wixuqff2pq'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'map',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'dozor.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'dozor.wsgi.application'


# Database
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        'NAME': 'main',
        'USER': '1',
        'HOST': 'localhost',
        'PASSWORD': '1',
        'PORT': '5432',
    },
}


# Password validation
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/1.10/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True


# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.10/howto/static-files/

STATIC_URL = '/static/'

但是,没有任何帮助。

 import django.contrib.gis.gdal.raster.source.GDALRaster

 jango.contrib.gis.gdal.error.GDALException: Could not find the GDAL library (tried "gdal111", "gdal110", "gdal19", "gdal18", "gdal17"). Try setting GDAL_LIBRARY_PATH in your settings

你还能建议我做什么?

0 个答案:

没有答案