简体   繁体   中英

Error: No module named staticfiles in django 1.3.1 + python 2.6? what's wrong

I didn't worked on the django project for somedays and now I return and I can't work on it. When I debug or run in eclipse aptana I get the "Error: No module named staticfiles" error.

  • I have even updated aptana to today's updates and no luck.
  • I have uninstalled the django, delete all files and reinstall.
  • If I import django with python in cmd (on windows) it is in the place I expect to be

But if I delete the "'django.contrib.staticfiles'," string in the "INSTALLED_APPS" from settings.py everything works fine but I have no access to the static files, as expected..

In those days I have installed Google app engine + python 2.5; can this be the problem and how to solve?

thank you very much*

Here are the steps I'd take to find out the problem:

  • verify that it's working correctly in the command-line (cmd.exe in windows) - just to remove the issues associated with Aptana. You need to do something like: C:\\Path\\to\\Python2.6\\python.exe manage.py runserver (NB: choose any management command that will check your settings.py). If this gives the same error, then you haven't got Django 1.3.1 installed in Python2.6 (you could install it, or you could set up a fresh virtualenv, see below)
  • once you've got it working in the command line, you just have to make sure that aptana is using the correct interpreter path. You need to check that you've defined it correctly (in your global preferences (the workspace settings) -- pydev python interpreter) and then are using it in the specific project -- (check the project settings that it is using the python interpreter you just defined )
  • NB: Django 1.3.1 can use python2.5, but not next version of django

Here is how I would avoid this in future:

  • use virtualenv[1] to avoid being dependent on the arbitrary nature of your installation history (once you've installed virtualenv in ANY version of python you can then specify which python when you set up the virtualenv: virtualenv -p C:\\Path\\to\\Python2.6\\python.exe ).
  • use virtualenv --no-site-packages to ensure you have no dependencies locally
  • use pip[2] to install all your python packages (problems may occur with packages with binary content - use easy_install for those)
  • use pip freeze > requirements.txt to record your dependencies (and add this file into your source code control)

[1] http://pypi.python.org/pypi/virtualenv

[2] http://pypi.python.org/pypi/pip

NB pip and easy_install are automatically installed into your new virtualenv

在新版Django中使用{% load static %}代替{% load staticfiles %} ,加载静态文件的语法发生了变化

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM