0

Am working arround zc.buildout. I deployed my project in my local apache server.

My issue is when I run it, I got an import error 'No module named raven.conf' But there is all the packages I specified in egg directory.

That is django trying to load packages from system's python package, not from the isolated buildout folder. How can I solve it,

Myproject
  bootstrap.py
  setup.py
  bin/
     buildout
     django
     django.wsgi
     .....
  eggs/
       raven-3.1.13-py2.7.egg
       ..........
  parts
  project
  develop-eggs
  src/
  some files
  django.wsgi
  myapp/
    files
    settings.py

buildout.cfg

[buildout]
parts = python
        django

develop = .
eggs = beautifulsoup       
       MySQL_python
       pymongo
       requests
       .......
       .......
       raven
       sqlalchemy

[python]
recipe = zc.recipe.egg
interpreter = python
eggs = ${buildout:eggs}

[django]
recipe = djangorecipe
wsgi = true
settings = settings
eggs = ${buildout:eggs}

Thanks in advance.

Jisson
  • 3,566
  • 8
  • 38
  • 71
  • my Exception location is /home/jisson/tests/t/src/myapp/myapis/logger/__init__.py in , line 7 . from raven.conf import setup_logging. Thats django not able to load the python packages in its egg directory. – Jisson Feb 21 '13 at 10:24
  • You can [edit] your question to add additional info. – Martijn Pieters Feb 21 '13 at 10:31
  • You can check what eggs are included in the `bin/django.wsgi` file. – Martijn Pieters Feb 21 '13 at 10:33
  • @ Martijn Pieters ,previously have a apache configuration issue, I point to different django.wgi other than bin/django.wsgi. Now I vave an internal server error. Can you have a look my apache log.http://pastie.org/6278742 – Jisson Feb 21 '13 at 10:51
  • when I run ./bin/django I got Error loading the settings module 'project.myapp.settings': No module named myapp.settingsjisson@DexLap05:~/tests/t – Jisson Feb 21 '13 at 10:53
  • my setting file in location t/src/myapp/settings.py – Jisson Feb 21 '13 at 10:55
  • If you are pointing Apache to a *different* `wsgi` file then you certainly cannot be sure you have all the right eggs. That's why Buildout generates a WSGI file *for you*. – Martijn Pieters Feb 21 '13 at 11:07
  • Now am pointing to the django.wsgi in bin/django.wsgi and ./bin/django and ./bin/django.wsgi working properly. But still I got a 500 error message. apache error log: http://pastie.org/6279742 – Jisson Feb 21 '13 at 11:13
  • bin/django.wsgi has all the eggs in sys.path – Jisson Feb 21 '13 at 11:16
  • We just solved your original issue then, didn't we? Your first problem was that you didn't use the buildout-provided `.wsgi` file. Now you have a new problem, namely that your template isn't being found. I think that would require a *new* question as that problem would change this question too much. You probably are relying on some relative path for your template and now it cannot be found because Django doesn't look in the right places with that path. – Martijn Pieters Feb 21 '13 at 13:17

1 Answers1

1

Did you checked that your Django project directories have the proper __init__.py files? This error often is due to that.

In your src/myapp directory, you should have a __init__.py file, so Python will get it as a module and can import it. The same for all you other directories inside myapp/ containing Python code. If you have an ImportError in your raven.conf directory, probably is because you don't have any __init__.py file in your conf/ dir.

José L. Patiño
  • 3,683
  • 2
  • 29
  • 28
  • ,__init__.py file in all directory, The project working without buildout – Jisson Feb 21 '13 at 10:13
  • So, what ``django.wsgi`` script are you passing to Apache configuration? Buildout creates one in the ``bin/`` directory, which points to the proper Python interpreter and adds all the paths needed. Maybe you're using another different WSGI config file? – José L. Patiño Feb 21 '13 at 10:18
  • my Exception location is /home/jisson/tests/t/src/DjangoApis/myapis/logger/__init__.py in , line 7 . from raven.conf import setup_logging – Jisson Feb 21 '13 at 10:21
  • I think , django doesn't trying to get the package from its eggs folder. – Jisson Feb 21 '13 at 10:22
  • 1
    Yes you are correct I piont to django.wsgi other than ./bin/django.wsgi. Thanks Jose – Jisson Feb 21 '13 at 10:27
  • I see. You have the egg "raven" and it's not loading. Perhaps you passed the wrong config file to Apache? You can see if buildout is importing it correctly by login into project shell with ``django shell`` command and then trying to manually ``from raven.conf import setup_logging``. If it works there, then problem is probably in Apache configuration. – José L. Patiño Feb 21 '13 at 10:29
  • Cool :) Sorry for the last outdated comment. Cheers! – José L. Patiño Feb 21 '13 at 10:32
  • I changed apache configuration , now it point to /home/jisson/tests/t/bin/django.wsgi, yea its working, But now I have a different issue, about the settings file. can you have a look (my apache log)and help me? http://pastie.org/6278742 – Jisson Feb 21 '13 at 10:35
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/24887/discussion-between-jisson-and-jose-l-patino) – Jisson Feb 21 '13 at 10:35
  • I have an internal server error, the apache log : mod_wsgi (pid=9217): Target WSGI script '/home/jisson/tests/t/bin/django.wsgi' cannot be loaded as Python module – Jisson Feb 21 '13 at 10:48
  • Can you take a look on [this other discussion](http://stackoverflow.com/questions/6454564/target-wsgi-script-cannot-be-loaded-as-python-module)? Probably it can help you with that problem... – José L. Patiño Feb 21 '13 at 14:40