我正在努力学习吉德扬戈的教程。我正在使用一台64位的windows-10计算机。我使用的是Python3.6和Django1.11
GeoDjango Windows Documentation
安装。我已经成功地完成了它告诉我的所有步骤,我还下载并运行了OSGeo4W,并以管理员身份成功地运行了cmd.exe中的路径
现在回到
Django Tutorial
Create a Spatial Database
:我在Postgres Sql中创建了一个数据库
我开始了一个叫Django的项目
吉德扬戈
,启动了一个名为
世界
我将设置中的数据库更改为
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'geodjango',
'USER': 'geo',
},
}
我在我的settings.py安装的应用程序中添加了以下内容
'django.contrib.gis',
'world',
我在
world
申请。我下载了zip文件并将其解压缩到我的数据文件夹中。我的数据文件夹中有以下文件
Use ogrinfo to examine spatial data
(我不知道该怎么办,所以忽略了这一部分)
我成功地
模型.py
就像上面说的
tutorial
from django.contrib.gis.db import models
class WorldBorder(models.Model):
# Regular Django fields corresponding to the attributes in the
# world borders shapefile.
name = models.CharField(max_length=50)
area = models.IntegerField()
pop2005 = models.IntegerField('Population 2005')
fips = models.CharField('FIPS Code', max_length=2)
iso2 = models.CharField('2 Digit ISO', max_length=2)
iso3 = models.CharField('3 Digit ISO', max_length=3)
un = models.IntegerField('United Nations Code')
region = models.IntegerField('Region Code')
subregion = models.IntegerField('Sub-Region Code')
lon = models.FloatField()
lat = models.FloatField()
# GeoDjango-specific: a geometry field (MultiPolygonField)
mpoly = models.MultiPolygonField()
# Returns the string representation of the model.
def __str__(self): # __unicode__ on Python 2
return self.name
然后教程要求我运行python manage.py makemigrations,当我这样做时,我得到以下错误
Error was: cannot import name 'GDALRaster'
我能做什么来修正这个错误
我试过了
pip install gdal
给了我一个错误
error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual C++ Build Tools": http://landinghub.visualstudio.com/visual-cpp-build-tools
所以我下载了微软Visual C++构建工具。试图逃跑
pip install gdal
现在我又犯了错误
`error: command 'C:\\Program Files (x86)\\Microsoft Visual Studio\\2017\\Community\\VC\\Tools\\MSVC\\14.14.26428\\bin\\HostX86\\x64\\cl.exe' failed with exit statu
s 2`