I have done everything said on the following page.
https://help.ubuntu.com/community/Django
but it gives me an error page.
MOD_PYTHON ERROR
ProcessId: 2220 Interpreter:
'localhost.localdomain'
ServerName:
'localhost.localdomain' DocumentRoot:
'/etc/apache2/htdocs'
URI: '/' Location:
'/' Directory: None Filename:
'/etc/apache2/htdocs' PathInfo:
'/'
Phase: 'PythonHandler'
Handler:
'django.core.handlers.modpython'
Traceback (most recent call last):
File
"/usr/lib/python2.6/dist-packages/mod_python/importer.py",
line 1537, in HandlerDispatch
default=default_handler, arg=req, silent=hlist.silent)
File
"/usr/lib/python2.6/dist-packages/mod_python/importer.py",
line 1229, in _process_target
result = _execute_target(config, req, object, arg)
File
"/usr/lib/python2.6/dist-packages/mod_python/importer.py",
line 1128, in _execute_target
result = object(arg)
File
"/usr/lib/pymodules/python2.6/django/core/handlers/modpython.py",
line 228, in handler
return ModPythonHandler()(req)
File
"/usr/lib/pymodules/python2.6/django/core/handlers/modpython.py",
line 191, in call
self.load_middleware()
File
"/usr/lib/pymodules/python2.6/django/core/handlers/base.py",
line 33, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:
File
"/usr/lib/pymodules/python2.6/django/utils/functional.py",
line 276, in getattr
self._setup()
File
"/usr/lib/pymodules/python2.6/django/conf/init.py",
line 40, in _setup
self._wrapped = Settings(settings_module)
File
"/usr/lib/pymodules/python2.6/django/conf/init.py",
line 75, in init
raise ImportError("Could not import settings '%s' (Is it on
sys.path? Does it have syntax
errors?): %s" % (self.SETTINGS_MODULE,
e))
ImportError: Could not import settings
'examples.settings' (Is it on sys.path? Does it have syntax errors?): No module named examples.settings
what could be wrong?
complete noob here.
If you are deploying django project for production under ubuntu server it is recommended to use WSGI. Just fallow the django documentation: https://docs.djangoproject.com/en/1.3/howto/deployment/modwsgi/
Installing apache with wsgi under ubuntu is easy:
apt-get install libapache2-mod-wsgi
In case you just want to explore django you do not need to setup apache or anything. Just use manage.py runserver instead.
Related
I am using Django 1.8 on Jython in Windows 10. Have created a simple Django project following the tutorial https://docs.djangoproject.com/en/1.8/intro/tutorial01. After packaging using buildwar(including jars), when I deploy the mysite.war archive in tomcat, I get an error.
My project name is mysite, I have referenced the Jython path in web.xml.
My project structure is
-mysite
-WEB-INF
-lib
-jruby-extras-fileservlet.jar
-jython.jar
-lib-python
-django
-doj
-polls
-application_settingspy.class
-application_settings.py
-eggs.pth
-web.xml
-wsgi
Error is
Traceback (most recent call last):
File "D:\jython27\Lib\modjy\modjy.py", line 80, in service
self.exc_handler.handle(req, resp, wsgi_environ, mx, (typ, value, tb) )
File "D:\jython27\Lib\modjy\modjy.py", line 76, in service
self.dispatch_to_application(req, resp, wsgi_environ)
File "D:\jython27\Lib\modjy\modjy.py", line 92, in dispatch_to_application
app_callable = self.get_app_object(req, environ)
File "D:\jython27\Lib\modjy\modjy_publish.py", line 68, in get_app_object
return self.get_app_object_old_style(req, environ)
File "D:\jython27\Lib\modjy\modjy_publish.py", line 120, in get_app_object_old_style
return self.load_object(source_filename, callable_name)
File "D:\jython27\Lib\modjy\modjy_publish.py", line 142, in load_object
self.raise_exc(NoCallable, "Error loading jython callable '%s': %s" % (callable_name, str(x)) )
File "D:\jython27\Lib\modjy\modjy.py", line 121, in raise_exc
raise exc_class(message)
modjy.modjy_exceptions.NoCallable: Error loading jython callable 'application': No module named mysite
The application_settings file shows:
from mysite.settings import *
CONTEXT_ROOT = "mysite"
I've followed this guide: https://forge.fiware.org/plugins/mediawiki/wiki/fiware/index.php/Identity_Management_-KeyRock-_Installation_and_Administration_Guide
When i run the server i get:
Traceback (most recent call last):
File "manage.py", line 23, in <module>
execute_from_command_line(sys.argv)
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 261, in fetch_command
commands = get_commands()
File "/usr/lib/python2.6/site-packages/django/core/management/__init__.py", line 107, in get_commands
apps = settings.INSTALLED_APPS
File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 49, in _setup
self._wrapped = Settings(settings_module)
File "/usr/lib/python2.6/site-packages/django/conf/__init__.py", line 132, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'openstack_dashboard.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named oslo.utils
I've tried using --pythonpath but to no avail. I've also ran ./run_tests.sh and here are the results: http://pastebin.com/6i7Ws5Ej.
System:
CentOS 6.5 x64,
python 2.6.6
Any idea how to solve this? any info i might have forgotten don’t hesitate to ask
Edit:
I've switched to ubuntu 12 to follow the tutorial step by step. I got keystone running but horizon still fails and gives me the same error.
A fix was also committed on KeyRock's Github account.
Here is the issue.
Manually updating pbr to 1.3.0 directly from python and pip solved all issues
I recently upgraded my Ubuntu to 14.04, and consulted this question to solve my erros, ImportError: No module named _io in ubuntu 14.04. That was solved perfectly.
I also checked out this question as it's similar to mine, Consistently getting ImportError: Could not import settings 'myapp.settings' error, but could not use the same solution.
I do not use manage.py in my project and I have done numerous exports of the PYTHON_PATH to no end of my issues. Here is my traceback;
Traceback (most recent call last):
File "/home/thabang/.virtualenvs/lottostar/bin/django-admin.py", line 5, in <module>
management.execute_from_command_line()
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 261, in fetch_command
commands = get_commands()
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 107, in get_commands
apps = settings.INSTALLED_APPS
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/conf/__init__.py", line 54, in __getattr__
self._setup(name)
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/conf/__init__.py", line 49, in _setup
self._wrapped = Settings(settings_module)
File "/home/thabang/.virtualenvs/lottostar/local/lib/python2.7/site-packages/django/conf/__init__.py", line 132, in __init__
% (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'lottostar.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named lottostar.settings
I found the problem:
The was an issue with the egg files during the virtualenv reinstall. Though the programs were there, they couldn't be found. I just performed another install of the requirements to refresh the egg info.
I have installed and probably right configurated apache2, mod_wsgi and python 2.7.5. The problem is that 127.0.0.1 is not opening (loading is just freezed) and I see following log in error.log:
[Wed Jun 19 14:49:11 2013] [notice] Apache/2.2.22 (Ubuntu) mod_wsgi/3.4 Python/2.7.3 configured -- resuming normal operations
Traceback (most recent call last):
File "/usr/local/lib/python2.7/site.py", line 548, in <module>
main()
File "/usr/local/lib/python2.7/site.py", line 530, in main
known_paths = addusersitepackages(known_paths)
File "/usr/local/lib/python2.7/site.py", line 266, in addusersitepackages
user_site = getusersitepackages()
File "/usr/local/lib/python2.7/site.py", line 241, in getusersitepackages
user_base = getuserbase() # this will also set USER_BASE
File "/usr/local/lib/python2.7/site.py", line 231, in getuserbase
USER_BASE = get_config_var('userbase')
File "/usr/local/lib/python2.7/sysconfig.py", line 516, in get_config_var
return get_config_vars().get(name)
File "/usr/local/lib/python2.7/sysconfig.py", line 449, in get_config_vars
import re
File "/usr/local/lib/python2.7/re.py", line 105, in <module>
import sre_compile
File "/usr/local/lib/python2.7/sre_compile.py", line 14, in <module>
import sre_parse
File "/usr/local/lib/python2.7/sre_parse.py", line 17, in <module>
from sre_constants import *
File "/usr/local/lib/python2.7/sre_constants.py", line 18, in <module>
from _sre import MAXREPEAT
ImportError: cannot import name MAXREPEAT
Tried to restart apache, but it's not working. Thanks for any help!
Just found solution. I checked 'sys.prefix' in my python's interpretator and it printed '/usr/local', but I had not set WSGIPythonHome in apache config (as written in mod_wsgi docs for this case). And just for experiment I set 'WSGIPythonHome /usr'. It's strange, but it resolves my problem, everything is fine now!
Im tired of trying to put this working :(
So, here is my problem:
Added to httpd.conf :
Location "/ps3t/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE ps3t.settings
PythonOption django.root /ps3t
PythonDebug On
PythonPath "['/home/fabriciols'] + sys.path"
/Location>
removed the "<" from localtion, but on my httd.conf have
but, when i access my site :
Mod_python error: "PythonHandler django.core.handlers.modpython"
Traceback (most recent call last):
File "/usr/lib/python2.4/site-packages/mod_python/apache.py", line 299, in HandlerDispatch
result = object(req)
File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 228, in handler
return ModPythonHandler()(req)
File "/usr/lib/python2.4/site-packages/django/core/handlers/modpython.py", line 191, in __call__
self.load_middleware()
File "/usr/lib/python2.4/site-packages/django/core/handlers/base.py", line 33, in load_middleware
for middleware_path in settings.MIDDLEWARE_CLASSES:
File "/usr/lib/python2.4/site-packages/django/utils/functional.py", line 268, in __getattr__
self._setup()
File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line 40, in _setup
self._wrapped = Settings(settings_module)
File "/usr/lib/python2.4/site-packages/django/conf/__init__.py", line 75, in __init__
raise ImportError, "Could not import settings '%s' (Is it on sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)
ImportError: Could not import settings 'ps3t.settings' (Is it on sys.path? Does it have syntax errors?): No module named ps3t.settings
my project structure :
/home/fabriciols/ - root dir
./ps3t - project
./ps3t/myps3t - app
every user has read perm in all files ...
what im doing wrong ? :/
find the solution, but i thing this isnt the best solution
chmod +rx -R /home/fabriciols/
i read that apache only need READ perm on dir, but it seems to need execute perm too :D