不知道如何继续这个项目。 花了很多时间寻找答案。
ImportError: Could not import settings 'myproject.settings' (Is it on sys.path?): No module named oscar
我使用djangohosting.ch 想要安装django-oscar 我不太熟悉django
我打算创建virtualenv / v /并在我的一个项目中启动并运行django-oscar。我们称之为myproject
我开始用djangohosting.ch的一键安装程序创建myproject 现在它安装在/ home / myuser / myproject
中我想我在dir / v /中正确安装了virtualenv,并且我使用了pip install django-oscar,我认为所有的发泄都非常好。我在/v/lib/python2.6/site-packages
中看到了一堆目录但我不确定我是否正确设置了PYTHONPATH。 我将/ myproject / RUN文件配置为
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
我按照this guide
中的settings.py设置编辑/myproject/myproject/settings.py
我根据指南编辑了urls.py.
我编辑了/ home / myuser / init / myproject文件这些行
PYTHONPATH="$HOME/v/lib"
DAEMON=$HOME/v/bin/python
我不知道我在说实话。我希望我更了解这一切。
感谢您帮助我
这是我得到的:
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
答案 0 :(得分:1)
我不确定djangohosting.ch是什么样子但是如果你有一个wsgi设置它应该看起来像这样:
的apache2 / CONF / httpd.conf中 这个文件有更多,但通常大多数是由您的主机设置的,您可能需要调整这些区域
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()
如果这不是您的设置,我至少会尝试将您的python路径更改为我在httpd.conf文件中的路径