错误是:无法在 Windows 8.1 中导入名称“GDALRaster" [英] Error was: cannot import name 'GDALRaster' in windows 8.1

查看:96
本文介绍了错误是:无法在 Windows 8.1 中导入名称“GDALRaster"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 这不是我的答案.因为我正在尝试在 windows 8.1 64bit 中开发:http://stackoverflow.com/questions/39037351/django-migration-cant-find-gdalraster(casino_locater) C:\Users\....\Desktop\Geolocation>python manage.py makemigrations………………………………………………django.core.exceptions.ImproperlyConfigured: 'django.contrib.gis.db.backends.postgis' 不是可用的数据库后端.尝试使用django.db.backends.XXX",其中 XXX 是以下之一:'mysql'、'oracle'、'postgresql'、'sqlite3'错误是:无法导入名称GDALRaster"

解决方案

仅适用于窗口用户:按照以下步骤将gdal安装到window环境中:第 1 步:安装 OSGeo4WOSGeo4W 安装程序使安装 GeoDjango 所需的 PROJ.4、GDAL 和 GEOS 库变得简单.首先,下载 OSGeo4W 安装程序并运行它.选择 Express Web-GIS 安装并单击下一步.在Select Packages"列表中,确保选择了 GDAL;MapServer 和 Apache 也默认启用,但 GeoDjango 不需要,可以安全地取消选中.单击下一步后,软件包将自动下载并安装,之后您可以退出安装程序.32 位:http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86.exe对于 64 位:http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe第二步:修改Windows环境为了使用 GeoDjango,您需要将 Python 和 OSGeo4W 目录添加到 Windows 系统路径,并创建 GDAL_DATA 和 PROJ_LIB 环境变量.下面的命令集,可通过 cmd.exe 执行,将进行设置:

`set OSGEO4W_ROOT=C:\OSGeo4W set PYTHON_ROOT=C:\Python27 set GDAL_DATA=%OSGEO4W_ROOT%\share\gdal set PROJ_LIB=%OSGEO4W_ROOT%\share\proj set PATH=%PATH%;%PYTHON%;%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\SessionManager\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%"`

<前>将上述脚本复制(不带单引号)到记事本或任何文本编辑器中,并通过 geodjango_setup.bat 保存文件名注:1执行这些命令需要管理员权限.为此,右键单击 geodjango_setup.bat 并选择以管理员身份运行.您需要注销并重新登录才能使设置生效.笔记2如果您自定义了 Python 或 OSGeo4W 安装目录,则需要相应地修改 OSGEO4W_ROOT 和/或 PYTHON_ROOT 变量.有关更多详细信息:https://docs.djangoproject.com/en/1.10/ref/contrib/gis/install/#windows

 It's not my answer. Because I am trying to develop in windows 8.1 64bit: http://stackoverflow.com/questions/39037351/django-migration-cant-find-gdalraster

(casino_locater) C:\Users\....\Desktop\Geolocation>python manage.py makemigrations
.............
..............
..............
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'

解决方案

 
Only for window users: 
Follow the below steps to install gdal into the window environment: 

Step 1: Install OSGeo4W

The OSGeo4W installer makes it simple to install the PROJ.4, GDAL, and GEOS libraries required by GeoDjango. First, download the OSGeo4W installer, and run it. Select Express Web-GIS Install and click next. In the ‘Select Packages’ list, ensure that GDAL is selected; MapServer and Apache are also enabled by default, but are not required by GeoDjango and may be unchecked safely. After clicking next, the packages will be automatically downloaded and installed, after which you may exit the installer.

for 32bit: http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86.exe
for 64bit: http://download.osgeo.org/osgeo4w/osgeo4w-setup-x86_64.exe

Step 2: Modify Windows environment

In order to use GeoDjango, you will need to add your Python and OSGeo4W directories to your Windows system Path, as well as create GDAL_DATA and PROJ_LIB environment variables. The following set of commands, executable with cmd.exe, will set this up:

`set OSGEO4W_ROOT=C:\OSGeo4W 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%" `


Copy (without single inverted commas) the above script into notepad or any text editor and save the file name by geodjango_setup.bat 

Note: 1 

Administrator privileges are required to execute these commands. To do this, right-click on geodjango_setup.bat and select Run as administrator. You need to log out and log back in again for the settings to take effect.

Note: 2

If you customised the Python or OSGeo4W installation directories, then you will need to modify the OSGEO4W_ROOT and/or PYTHON_ROOT variables accordingly. 

For more details : https://docs.djangoproject.com/en/1.10/ref/contrib/gis/install/#windows

这篇关于错误是:无法在 Windows 8.1 中导入名称“GDALRaster"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆