Friday, December 3, 2010

Django/PYTHONPATH gotcha

Just picking up django again after a while away and had had some problems with the following error when running 'django-admin.py runserver --settings=mysite.settings'

Error: Could not import settings 'mysite.settings' (Is it on sys.path? Does it have syntax errors?): No module named mysite.settings

Google was not my friend as all of the returned results were to do with apache config etc

Turned out I'd simply forgotten to put the current working directory (.) in the PYTHONPATH (e.g export PYTHONPATH=.:$APPENGINEPATH:$APPENGINEPATH/lib/yaml/lib:$APPENGINEPATH/lib/webob:$APPENGINEPATH/lib/ipaddr:$APPENGINEPATH/lib/fancy_urllib
) doh!

2 comments:

  1. Managing Python environments, module paths, and framework configurations is an essential aspect of developing reliable web applications. The troubleshooting approach presented in this article provides useful insights for students and developers working on Python Projects For Final Year, where understanding package management and application deployment is just as important as writing code.

    ReplyDelete
  2. The article also emphasizes how a strong foundation in Python programming and framework configuration can significantly reduce debugging time and improve productivity. Learning these practical skills through comprehensive resources such as Python Training Courses enables developers to build, deploy, and maintain Python applications with greater confidence and efficiency.

    ReplyDelete