0

Dont know how to get on with this project. Spent many hours looking for the answer.

ImportError: Could not import settings 'myproject.settings' (Is it on sys.path?): No module named oscar

I use djangohosting.ch Want to install django-oscar Im not so familiar with django

Its was my intention to create virtualenv /v/ and get django-oscar up and running in one of my projects. lets call it myproject

I started creating myproject with djangohosting.ch's 1-click installer now its installed in /home/myuser/myproject

I think I got the virtualenv correctly installed in dir /v/ , and I used pip install django-oscar and I think that all vent very well. I see a bunch of directories in the /v/lib/python2.6/site-packages

But I am not sure if I set PYTHONPATH correctly. I configured the /myproject/RUN file to

PYTHONPATH=/home/myuser/v/lib/python2.6/site-packages:/home/myuser/v/lib/python2.6/site-packages/django:/home/myuser/v/lib/python2.6/site-packages/oscar:/home/myuser/myproject:/home/myuser/myproject/myproject:. python manage.py runserver 127.0.0.1:62202

I followed the setup of settings.py from this guide

edited /myproject/myproject/settings.py

And I edited the urls.py according to the guide.

I edited the /home/myuser/init/myproject file these lines

PYTHONPATH="$HOME/v/lib"
DAEMON=$HOME/v/bin/python

Havent got a clue what Im doing to be honest. I wish I understand more of all this.

Thank You for helping me

Here is what I get:

michaelh@s10:~$ cd myproject
michaelh@s10:~/myproject$ python manage.py syncdb
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 443, in execute_from_command_line
    utility.execute()
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 382, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 261, in fetch_command
    klass = load_command_class(app_name, subcommand)
  File "/usr/lib/pymodules/python2.6/django/core/management/__init__.py", line 69, in load_command_class
    module = import_module('%s.management.commands.%s' % (app_name, name))
  File "/usr/lib/pymodules/python2.6/django/utils/importlib.py", line 35, in import_module
    __import__(name)
  File "/usr/lib/pymodules/python2.6/django/core/management/commands/syncdb.py", line 8, in <module>
    from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal
  File "/usr/lib/pymodules/python2.6/django/core/management/sql.py", line 6, in <module>
    from django.db import models
  File "/usr/lib/pymodules/python2.6/django/db/__init__.py", line 11, in <module>
    if DEFAULT_DB_ALIAS not in settings.DATABASES:
  File "/usr/lib/pymodules/python2.6/django/utils/functional.py", line 184, in inner
    self._setup()
  File "/usr/lib/pymodules/python2.6/django/conf/__init__.py", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/lib/pymodules/python2.6/django/conf/__init__.py", line 95, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'myproject.settings' (Is it on sys.path?): No module named oscar
user2717364
  • 1
  • 1
  • 2

1 Answers1

1

I'm not sure what djangohosting.ch looks like but if you have a wsgi setup it should look something like this:

apache2/conf/httpd.conf This file has more but usually has most of it setup by your host, these areas you may have to adjust

WSGIDaemonProcess cpm processes=5 python-path=/home/myuser/myproject/:/home/myuser/myproject/myproject:/home/myuser/v/lib/python2.6/ threads=1

WSGIScriptAlias / /home/myuser/myproject/wsgi.py

wsgi.py

import os
import sys
from django.core.handlers.wsgi import WSGIHandler

sys.stdout = sys.stderr

from site import addsitedir
addsitedir('/home/myuser/v/lib/python2.6/site-packages')

from os.path import abspath, dirname, join
from django.conf import settings

os.environ['DJANGO_SETTINGS_MODULE'] = 'myproject.settings'
application = WSGIHandler()

If this isn't your setup I would at least try changing your python path to what I have in the httpd.conf file

Will Farley
  • 670
  • 1
  • 8
  • 19
  • Thanks alot, I want to try it out :) I have found the wsgi.py in /myproject/myproject/ and I have altered it. Cant find the place to adjust WSGIDaemonProcess though. Any clue where I could find it? – user2717364 Aug 26 '13 at 12:05
  • depends where apache2 is located. Once you find that, httpd.conf will be here: apache2/conf/httpd.conf Might be somewhere within your project folder, ie ~/myproject/apache2/ – Will Farley Aug 26 '13 at 13:04
  • Hi I found the file lighttpd.conf in /home/myuser/lighttpd/. could that be it? in same directory is file named django.conf – user2717364 Aug 26 '13 at 14:06
  • Im so confused :) Here is info about the 1-click installer I used to install myproject http://www.wservices.ch/en/info/django-installer/ - I'd like to understand how it all works. Can anybody please teach me a little? I see a bunch of files organised in a bunch of libraries, and I know how to build things in Django, but Im totally confused by the file structure. As example I think I found some of the files in my library, that I need to edit. They are /lighttpd/lighttpd.conf, /lighttpd/django.conf, /init/lighttpd, /init/myproject, /myproject/RUN, /myproject/myproject/settings.py – user2717364 Aug 28 '13 at 08:46
  • More info on what I did After I 1-click installed the mypriject: I installed a virtualenv i /v/ and pip installed django-oscar and tried to follow their guide http://django-oscar.readthedocs.org/en/latest/internals/getting_started.html and then I got stuck with this error – user2717364 Aug 28 '13 at 08:50
  • My mistake was that I simply didnt activate the virtualanv. – user2717364 Aug 29 '13 at 10:51