I can't run Django server and this is the problem :
MacBook-Pro-di-viv:vivsite viv$ python3 manage.py runserver
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 354, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.5/site-packages/django/core/management/__init__.py", line 303, in execute
settings.INSTALLED_APPS
File "/usr/local/lib/python3.5/site-packages/django/conf/__init__.py", line 48, in __getattr__
self._setup(name)
File "/usr/local/lib/python3.5/site-packages/django/conf/__init__.py", line 44, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/lib/python3.5/site-packages/django/conf/__init__.py", line 92, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/local/Cellar/python3/3.5.1/Frameworks/Python.framework/Versions/3.5/lib/python3.5/importlib/__init__.py", line 121, in import_module
raise TypeError(msg.format(name))
TypeError: the 'package' argument is required to perform a relative import for '.settings'
I had this problem after this Python command line:
>>> settings.configure()
Can someone help me? Thanks!
I asssume that your settings file is called ".settings.py".
Did you try to rename it without starting by "." ?
Related
Trying to run python django tests script inside AWS Linux:
./runtests.sh ./myapp/manage.py
and get the below error. Does anyone know what this means and what I should do? manage.py is in the main directory and test_settings.py is in a sub directory called myapp
./deploy-scripts/runtests.sh ./myapp/manage.py
Traceback (most recent call last):
File "manage.py", line 18, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/python37/lib/python3.7/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
utility.execute()
File "/usr/local/python37/lib/python3.7/site-packages/django/core/management/__init__.py", line 363, in execute
settings.INSTALLED_APPS
File "/usr/local/python37/lib/python3.7/site-packages/django/conf/__init__.py", line 82, in __getattr__
self._setup(name)
File "/usr/local/python37/lib/python3.7/site-packages/django/conf/__init__.py", line 69, in _setup
self._wrapped = Settings(settings_module)
File "/usr/local/python37/lib/python3.7/site-packages/django/conf/__init__.py", line 170, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/usr/local/python37/lib/python3.7/importlib/__init__.py", line 122, in import_module
raise TypeError(msg.format(name))
TypeError: the 'package' argument is required to perform a relative import for './myapp/manage.py.test_settings'
./deploy-scripts/runtests.sh: line 57: flake8: command not found
------------------------
There were failed tests!
Scroll up for details
I am following an installation in lfs to insert a check out page in my website. I have copies all the instruction but after I tried to mia it produces an error.
(my_project) PS C:\my_project\src> python manage.py migrate
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "C:\my_project\lib\site-
packages\django\core\management\__init__.py", line 367, in
execute_from_command_line
utility.execute()
File "C:\my_project\lib\site-
packages\django\core\management\__init__.py", line 341, in execute
django.setup()
File "C:\my_project\lib\site-packages\django\__init__.py", line 27, in
setup
apps.populate(settings.INSTALLED_APPS)
File "C:\my_project\lib\site-packages\django\apps\registry.py", line 85,
in populate
app_config = AppConfig.create(entry)
File "C:\my_project\lib\site-packages\django\apps\config.py", line 90, in
create
module = import_module(entry)
File "c:\python27\Lib\importlib\__init__.py", line 37, in import_module
__import__(name)
ImportError: No module named lfs_theme
(my_project) PS C:\my_project\src>
I have a Django (version 1.9) application running with python 2.7.10 and I'm using Virtualenv.
Running the application with ./manage.py runserver I've no error, but when I try to run in debug I get django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
Here is the Pycharm debugging configuration:
Any idea why?
Here is the complete stack trace:
/Users/matteobetti/Progetti/Enydros/enysoft/bin/python ./manage.py runserver
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/core/management/__init__.py", line 350, in execute_from_command_line
utility.execute()
File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/core/management/__init__.py", line 342, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/core/management/__init__.py", line 176, in fetch_command
commands = get_commands()
File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/utils/lru_cache.py", line 100, in wrapper
result = user_function(*args, **kwds)
File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/core/management/__init__.py", line 71, in get_commands
for app_config in reversed(list(apps.get_app_configs())):
File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/apps/registry.py", line 137, in get_app_configs
self.check_apps_ready()
File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/apps/registry.py", line 124, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
I add import django e django.setup before execute_from_command_line(sys.argvs)
and I get this stack trace:
Traceback (most recent call last):
File "/Users/matteobetti/Progetti/Enydros/enysoft/manage.py", line 10, in <module>
django.setup()
File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/Users/matteobetti/Progetti/Enydros/enysoft/frontend/apps.py", line 2, in <module>
from frontend.services.container import app_context
File "/Users/matteobetti/Progetti/Enydros/enysoft/frontend/services/container.py", line 1, in <module>
from frontend.services.enysoft_services import RService, FixedSizeDirectoryCache, TubeSectionService, CsvSanifier
File "/Users/matteobetti/Progetti/Enydros/enysoft/frontend/services/enysoft_services.py", line 5, in <module>
import rpy2.robjects as ro
File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/rpy2/robjects/__init__.py", line 15, in <module>
import rpy2.rinterface as rinterface
File "/Users/matteobetti/Progetti/Enydros/enysoft/lib/python2.7/site-packages/rpy2/rinterface/__init__.py", line 16, in <module>
tmp = subprocess.check_output(("R", "RHOME"), universal_newlines=True)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 566, in check_output
process = Popen(stdout=PIPE, *popenargs, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 710, in __init__
errread, errwrite)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/subprocess.py", line 1335, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
Another thing to say is that my colleagues with Linux have no problem with the same virtualenv configuration, the only one that has a problem is me, using MacOs.
Try to add you settings file to system PATH. In my projects settings are in the folder /project_name/project_name/settings/development.py (that is slightly different from standard way). And in my case Evironment variables string is
DJANGO_SETTINGS_MODULE=project_name.settings.development;PYTHONUNBUFFERED=1
So change it according to your parameters and then try to run server again. I hope this helps.
I am trying to use django in appengine. I have followed the installation documentation and setup the project. But ./manage.py runserver command is generating error.
Traceback is,
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/salman/projects/appengine/banglapy/django/core/management/__init__.py", line 453, in execute_from_command_line
utility.execute()
File "/home/salman/projects/appengine/banglapy/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/salman/projects/appengine/banglapy/django/core/management/__init__.py", line 263, in fetch_command
app_name = get_commands()[subcommand]
File "/home/salman/projects/appengine/banglapy/django/core/management/__init__.py", line 109, in get_commands
apps = settings.INSTALLED_APPS
File "/home/salman/projects/appengine/banglapy/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/home/salman/projects/appengine/banglapy/django/conf/__init__.py", line 48, in _setup
self._wrapped = Settings(settings_module)
File "/home/salman/projects/appengine/banglapy/django/conf/__init__.py", line 132, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/home/salman/projects/appengine/banglapy/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/salman/projects/appengine/banglapy/banglapy/settings.py", line 6, in <module>
from djangoappengine.settings_base import *
File "/home/salman/projects/appengine/banglapy/djangoappengine/settings_base.py", line 8, in <module>
from djangoappengine.utils import on_production_server, have_appserver
File "/home/salman/projects/appengine/banglapy/djangoappengine/utils.py", line 24, in <module>
"Error was: %s" % e)
Exception: Could not get appid. Is your app.yaml file missing? Error was: cannot import name old_dev_appserver
how can I resolve this issue?
Google removed the old dev_appserver from the SDK in version 1.9.17. There is an issue on the djangoappengine project about it as well.
https://github.com/django-nonrel/djangoappengine/issues/95
OS X, Python 2.7, a fresh virtualenv:
virtualenv bar
source bar/bin/activate
pip install django --upgrade
django-admin.py startproject foo
cd foo
python manage.py runserver
Then I immediately get this:
Traceback (most recent call last):
File "manage.py", line 14, in <module>
execute_manager(settings)
File "/Users/xyz/.virtualenvs/bar/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/Users/xyz/.virtualenvs/bar/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/xyz/.virtualenvs/bar/lib/python2.7/site-packages/django/core/management/base.py", line 191, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/xyz/.virtualenvs/bar/lib/python2.7/site-packages/django/core/management/base.py", line 209, in execute
translation.activate('en-us')
File "/Users/xyz/.virtualenvs/bar/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 100, in activate
return _trans.activate(language)
File "/Users/xyz/.virtualenvs/bar/lib/python2.7/site-packages/django/utils/translation/__init__.py", line 43, in __getattr__
if settings.USE_I18N:
File "/Users/xyz/.virtualenvs/bar/lib/python2.7/site-packages/django/utils/functional.py", line 276, in __getattr__
self._setup()
File "/Users/xyz/.virtualenvs/bar/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
self._wrapped = Settings(settings_module)
File "/Users/xyz/.virtualenvs/bar/lib/python2.7/site-packages/django/conf/__init__.py", line 139, in __init__
logging_config_func(self.LOGGING)
File "/Users/xyz/.virtualenvs/bar/lib/python2.7/site-packages/django/utils/dictconfig.py", line 553, in dictConfig
dictConfigClass(config).configure()
File "/Users/xyz/.virtualenvs/bar/lib/python2.7/site-packages/django/utils/dictconfig.py", line 321, in configure
del logging._handlerList[:]
AttributeError: 'module' object has no attribute '_handlerList'
What's going wrong?
This issue seems somehow related to virtualenvwrapper, and my own stupidity; creating a virtualenv manually has resolved it.