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
Related
I'm relatively new to Django and programming, so I have no idea what caused this error or how to fix it. I asked another question related to the same error but got no responses so here's a simpler version.
When I run Django-admin check (along with various other commands not including run server) I get the following error.
django.core.exceptions.ImproperlyConfigured: Requested setting LANGUAGE_CODE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
I have spent hours googling and nothing I find works (I either get this error or a module not found error). What can I do?
here's the full traceback:
Traceback (most recent call last):
File "/Users/linnea/opt/miniconda3/bin/django-admin", line 8, in <module>
sys.exit(execute_from_command_line())
File "/Users/linnea/opt/miniconda3/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
utility.execute()
File "/Users/linnea/opt/miniconda3/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/linnea/opt/miniconda3/lib/python3.7/site-packages/django/core/management/base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/linnea/opt/miniconda3/lib/python3.7/site-packages/django/core/management/base.py", line 371, in execute
output = self.handle(*args, **options)
File "/Users/linnea/opt/miniconda3/lib/python3.7/site-packages/django/core/management/commands/check.py", line 69, in handle
databases=options['databases'],
File "/Users/linnea/opt/miniconda3/lib/python3.7/site-packages/django/core/management/base.py", line 396, in check
databases=databases,
File "/Users/linnea/opt/miniconda3/lib/python3.7/site-packages/django/core/checks/registry.py", line 70, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "/Users/linnea/opt/miniconda3/lib/python3.7/site-packages/django/core/checks/translation.py", line 60, in check_language_settings_consistent
get_supported_language_variant(settings.LANGUAGE_CODE)
File "/Users/linnea/opt/miniconda3/lib/python3.7/site-packages/django/conf/__init__.py", line 83, in __getattr__
self._setup(name)
File "/Users/linnea/opt/miniconda3/lib/python3.7/site-packages/django/conf/__init__.py", line 68, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting LANGUAGE_CODE, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Edit: I get the module not found error (no module named ) when I set the Django settings module
The problem is that Django cannot find your settings.py file to run the app. You need to set the environment variable DJANGO_SETTINGS_MODULE to point to you settings.py or if you're using an IDE just add it to your project config.
I've created a completely empty PyDev project (NOT "PyDev Django", just "PyDev"), with this single file in it:
import unittest
class Test(unittest.TestCase):
def testName(self):
print "hello world"
And when I either right-click on the file and select "Run As"->"Python unit test", or press CTRL+F9 and click on "testName", I get this error:
Traceback (most recent call last):
File "C:\Program Files\Brainwy\LiClipse 1.2.0\plugins\org.python.pydev_3.8.0.201409251617\pysrc\runfiles.py", line 201, in <module>
main()
File "C:\Program Files\Brainwy\LiClipse 1.2.0\plugins\org.python.pydev_3.8.0.201409251617\pysrc\runfiles.py", line 26, in main
import pydev_runfiles
File "C:\Program Files\Brainwy\LiClipse 1.2.0\plugins\org.python.pydev_3.8.0.201409251617\pysrc\pydev_runfiles.py", line 5, in <module>
django.setup()
File "C:\Python27\lib\site-packages\django\__init__.py", line 20, in setup
configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 46, in __getattr__
self._setup(name)
File "C:\Python27\lib\site-packages\django\conf\__init__.py", line 40, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting LOGGING_CONFIG, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
If I put this in the file:
if __name__ == "__main__":
unittest.main()
and execute it using "Run As"->"Python Run", it works fine, but of course it's inconvenient in case there are many tests in the file.
How do I get PyDev to execute the unit tests without Django?
Solved by updating LiClipse from 1.2.0 to 1.4.0 :)
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!
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.