私はdjango 1.6bとpython 3.3を使用していますが、このインポートエラーが発生します.
./manage.py runserver
Validating models...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x104ae4d40>
Traceback (most recent call last):
File "/opt/boxen/pyenv/versions/side-project/lib/python3.3/site-packages/django/utils/autoreload.py", line 93, in wrapper
fn(*args, **kwargs)
File "/opt/boxen/pyenv/versions/side-project/lib/python3.3/site-packages/django/core/management/commands/runserver.py", line 97, in inner_run
self.validate(display_num_errors=True)
File "/opt/boxen/pyenv/versions/side-project/lib/python3.3/site-packages/django/core/management/base.py", line 308, in validate
num_errors = get_validation_errors(s, app)
File "/opt/boxen/pyenv/versions/side-project/lib/python3.3/site-packages/django/core/management/validation.py", line 34, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/opt/boxen/pyenv/versions/side-project/lib/python3.3/site-packages/django/db/models/loading.py", line 196, in get_app_errors
self._populate()
File "/opt/boxen/pyenv/version/side-project/lib/python3.3/site-packages/django/db/models/loading.py", line 78, in _populate
self.load_app(app_name)
File "/opt/boxen/pyenv/versions/side-project/lib/python3.3/site-packages/django/db/models/loading.py", line 99, in load_app
models = import_module('.models', app_name)
File "/opt/boxen/pyenv/versions/side-project/lib/python3.3/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Users/moi/Projects/sos/dealerships/models.py", line 4, in <module>
from django.contrib.gis.db import models # as geomodels
File "/opt/boxen/pyenv/versions/side-project/lib/python3.3/site-packages/django/contrib/gis/db/models/__init__.py", line 8, in <module>
from django.contrib.gis.db.models.manager import GeoManager
File "/opt/boxen/pyenv/versions/side-project/lib/python3.3/site-packages/django/contrib/gis/db/models/manager.py", line 2, in <module>
from django.contrib.gis.db.models.query import GeoQuerySet
File "/opt/boxen/pyenv/versions/side-project/lib/python3.3/site-packages/django/contrib/gis/db/models/query.py", line 6, in <module>
from django.contrib.gis.db.models.fields import get_srid_info, PointField, LineStringField
File "/opt/boxen/pyenv/versions/side-project/lib/python3.3/site-packages/django/contrib/gis/db/models/fields.py", line 4, in <module>
from django.contrib.gis import forms
File "/opt/boxen/pyenv/versions/side-project/lib/python3.3/site-packages/django/contrib/gis/forms/__init__.py", line 2, in <module>
from .fields import (GeometryField, GeometryCollectionField, PointField,
File "/opt/boxen/pyenv/versions/side-project/lib/python3.3/site-packages/django/contrib/gis/forms/fields.py", line 11, in <module>
from django.contrib.gis.geos import GEOSException, GEOSGeometry, fromstr
ImportError: cannot import name GEOSException
これは、私が gis 用に用意した唯一のコードです。
from django.contrib.gis.db import models as geomodels
from django.utils.translation import ugettext as _
from django.contrib.localflavor.us.models import USStateField
class UsLocation(geomodels.Model):
address_1 = geomodels.CharField(_("address"), max_length=128)
address_2 = geomodels.CharField(_("address cont'd"), max_length=128, blank=True)
city = geomodels.CharField(_("city"), max_length=64, default="Kansas City")
state = USStateField(_("state"), default="KO")
zip_code = geomodels.CharField(_("zip code"), max_length=5, default="16874")
今のところ、住所モデルに gis ヘルパーを使用しないつもりですが、このインポート例外の原因はわかりません。django 1.5/1.6 リリースを確認したところ、同じ行がありました。1.6bw/ python 3.3.2 を使用している私と何か関係があるのだろうか?