python 导入库问题
最终解决如下面:我不知道有没有多余的空间
from django.conf import settings
from sys import pathpath.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
版权声明:本文博客原创文章,博客,未经同意,不得转载。