码迷,mamicode.com
首页 > 编程语言 > 详细

python 导入库问题

时间:2014-08-12 00:42:43      阅读:240      评论:0      收藏:0      [点我收藏+]

标签:django   python   

最后的解决如下:不知道有没有多余的地方

from django.conf import settings

from sys import path
path.extend([‘/home/zoueswebsite‘, ‘/home/zoueswebsite/blog‘, ‘/home/zoueswebsite/zoueswebsite‘])
import os

os.environ[‘DJANGO_SETTINGS_MODULE‘] = ‘zoueswebsite.settings‘


第一版本错误:

设置如下:

from django.conf import settings
settings.configure()
from sys import path
path.extend([‘/home/zoueswebsite‘, ‘/home/zoueswebsite/blog‘, ‘/home/zoueswebsite/zoueswebsite‘])
from blog.models import *

错误:

Traceback (most recent call last):
  File "xmlgenerator.py", line 20, in <module>
    for num, value in enumerate(Category.objects.all()):
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 96, in __iter__
    self._fetch_all()
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 857, in _fetch_all
    self._result_cache = list(self.iterator())
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py", line 220, in iterator
    for row in compiler.results_iter():
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 713, in results_iter
    for rows in self.execute_sql(MULTI):
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 776, in execute_sql
    sql, params = self.as_sql()
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 83, in as_sql
    out_cols, s_params = self.get_columns(with_col_aliases)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 231, in get_columns
    col_aliases)
  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 306, in get_default_columns
    r = ‘%s.%s‘ % (qn(alias), qn2(field.column))

  File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py", line 61, in quote_name_unless_alias
    r = self.connection.ops.quote_name(name)
  File "/usr/local/lib/python2.7/dist-packages/django/db/backends/dummy/base.py", line 15, in complain
    raise ImproperlyConfigured("settings.DATABASES is improperly configured. "
django.core.exceptions.ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

第一版本中:

注释掉这一行#path.extend([‘/home/zoueswebsite‘, ‘/home/zoueswebsite/blog‘, ‘/home/zoueswebsite/zoueswebsite‘])
会报错:


root@AY140715013539708c0eZ:~# python xmlgenerator.py
Traceback (most recent call last):
  File "xmlgenerator.py", line 11, in <module>
    from blog.models import *
ImportError: No module named blog.models

第一版本中:

如果注释掉os.environ[‘DJANGO_SETTINGS_MODULE‘] = ‘zoueswebsite.settings‘ 但是export 包含这个设置的时候 是无变化的 但是当我unset 的时候 就会报错:

报的错误是第一个错误

第一版本中:

如果注释掉:

#from django.conf import settings

是无关紧要的

第二版本错误:

from django.conf import settings
settings.configure()
from blog.models import *

EROROR;

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named blog

python 导入库问题,布布扣,bubuko.com

python 导入库问题

标签:django   python   

原文地址:http://blog.csdn.net/zouyee/article/details/38502423

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!