2016-11-26 60 views
1

我有一箇舊的DJango應用程序,它使用正常但突然崩潰。我用測試它:Django manage.py 1.6.11導入設置時突然崩潰

cd /opt/formshare/src/formshare/ 
export PYTHONPATH=$PYTHONPATH:/opt/formshare/src/formshare 
export DJANGO_SETTINGS_MODULE=formshare.settings.default_settings 
python manage.py validate 

但現在我得到這個錯誤:

(formshare) bash-4.3$ python manage.py validate 
Your environment is:"formshare.settings.default_settings" 
Traceback (most recent call last): 
    File "manage.py", line 21, in <module> 
    execute_from_command_line(sys.argv) 
    File "/opt/formshare/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line 
    utility.execute() 
    File "/opt/formshare/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/opt/formshare/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command 
    commands = get_commands() 
    File "/opt/formshare/lib/python2.7/site-packages/django/core/management/__init__.py", line 107, in get_commands 
    apps = settings.INSTALLED_APPS 
    File "/opt/formshare/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__ 
    self._setup(name) 
    File "/opt/formshare/lib/python2.7/site-packages/django/conf/__init__.py", line 49, in _setup 
    self._wrapped = Settings(settings_module) 
    File "/opt/formshare/lib/python2.7/site-packages/django/conf/__init__.py", line 132, in __init__ 
    % (self.SETTINGS_MODULE, e) 
ImportError: Could not import settings 'formshare.settings.default_settings' (Is it on sys.path? Is there an import error in the settings file?): cannot import name OrderedDict 

我使用:

virtualenv=15.0.2 
Python=2.7.11 
amqp==2.1.1 
billiard==3.3.0.23 
celery==3.1.15 
dict2xml==1.3 
Django==1.6.11 
django-braces==1.10.0 
django-celery==3.1.16 
django-cors-headers==0.13 
django-db-readonly==0.3.2 
django-digest==1.13 
django-filter==0.7 
django-guardian==1.2.4 
django-nose==1.4.2 
django-oauth-toolkit==0.7.2 
django-registration-redux==1.1 
django-reversion==1.8.4 
django-taggit==0.12.1 
django-templated-email==0.4.9 
djangorestframework==2.4.3 
djangorestframework-csv==1.3.3 
dpath==1.2.post70 
elaphe==0.5.6 
FormEncode==1.3.1 
gdata==2.0.18 
httmock==1.2.2 
httplib2==0.9 
jdcal==1.3 
jsonfield==0.9.23 
kombu==4.0.0 
librabbitmq==1.5.2 
linecache2==1.0.0 
lxml==3.4.0 
Markdown==2.5 
mock==1.0.1 
modilabs-python-utils==0.1.5 
nose==1.3.7 
numpy==1.11.2 
oauthlib==2.0.1 
openpyxl==2.0.5 
pandas==0.12.0 
Pillow==2.5.3 
poster==0.8.1 
psycopg2==2.5.4 
pybamboo==0.5.8.1 
pylibmc==1.3.0 
pymongo==2.7.2 
python-dateutil==2.6.0 
python-digest==1.7 
-e git+https://github.com/qlands/[email protected]87752d819cb6387f75569dbea9a5288aa6f#egg=python_json2xlsclient 
pytz==2014.7 
-e git+https://github.com/XLSForm/[email protected]#egg=pyxform 
recaptcha-client==1.0.6 
requests==2.4.1 
savReaderWriter==3.4.2 
simplejson==2.6.2 
six==1.10.0 
South==1.0 
traceback2==1.4.0 
unicodecsv==0.9.4 
unittest2==1.1.0 
vine==1.1.3 
xlrd==0.9.3 
xlwt==0.7.5 

我嘗試添加設置的路徑和設置驗證但沒有任何工作。

有什麼想法可以改變以及如何改正它?

回答

0

django進程似乎沒有看到您的formshare.settings.default_settings。如果沒有看到項目結構,很難確切知道發生了什麼,但可能會檢查一些事情。

  • 如果您使用的是python 2.x,那麼formshare /和settings /目錄下都有一個__init__.py文件嗎?
  • 嘗試添加/ opt/formshare/src /到python路徑而不是(或除了)你擁有的。

一個招,我經常嘗試確保蟒蛇路徑是正確的:當我在virtualenv中很活躍,我會進入一個python殼(不Django的外殼),然後嘗試使用下面的內容:

import formshare 
from formshare import settings 
from fomrmshare.settings import default_settings 

可能由這些產生的錯誤消息也可能有助於找出問題。

+0

感謝。這幫助我將錯誤追溯到更新的庫並使應用程序崩潰。 – QLands