I cannot figure how to import correctly an existing Django project in Eclipse/Pydev, and I can't find my way in the documentation of Pydev. My question is pretty simple : I have an existing project from a different computer, that I want to migrate on a new one.
I installed Eclipse and Pydev on the new machine, and everything seems normal for a new project: I can create a new Django project and run it without issue. I also have been able to import my pre-existing project, but when I run the project, I encounter the following error :
Finding files... done.
Importing test modules ... Traceback (most recent call last):
File "/home/francois/.p2/pool/plugins/org.python.pydev.core_9.3.0.202203051235/pysrc/_pydev_runfiles/pydev_runfiles.py", line 468, in __get_module_from_str
mod = __import__(modname)
File "/home/francois/eclipse-workspace/Test/Test/urls.py", line 20, in <module>
path('', include('myApp.urls')),
File "/home/francois/anaconda3/envs/ipaidenv/lib/python3.10/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/home/francois/anaconda3/envs/ipaidenv/lib/python3.10/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/francois/eclipse-workspace/Test/myApp/urls.py", line 2, in <module>
from . import views
File "/home/francois/eclipse-workspace/Test/myApp/views.py", line 2, in <module>
from myApp.forms import CreateGroupForm, JoinGroupForm
File "/home/francois/eclipse-workspace/Test/myApp/forms.py", line 4, in <module>
from .models import Group, User
File "/home/francois/eclipse-workspace/Test/myApp/models.py", line 2, in <module>
from django.contrib.auth.models import AbstractUser
File "/home/francois/anaconda3/envs/ipaidenv/lib/python3.10/site-packages/django/contrib/auth/models.py", line 3, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/home/francois/anaconda3/envs/ipaidenv/lib/python3.10/site-packages/django/contrib/auth/base_user.py", line 48, in <module>
class AbstractBaseUser(models.Model):
File "/home/francois/anaconda3/envs/ipaidenv/lib/python3.10/site-packages/django/db/models/base.py", line 108, in __new__
app_config = apps.get_containing_app_config(module)
File "/home/francois/anaconda3/envs/ipaidenv/lib/python3.10/site-packages/django/apps/registry.py", line 253, in get_containing_app_config
self.check_apps_ready()
File "/home/francois/anaconda3/envs/ipaidenv/lib/python3.10/site-packages/django/apps/registry.py", line 136, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
ERROR: Module: Test.urls could not be imported (file: /home/francois/eclipse-workspace/Test/Test/urls.py).
done.
Traceback (most recent call last):
File "/home/francois/.p2/pool/plugins/org.python.pydev.core_9.3.0.202203051235/pysrc/runfiles.py", line 273, in <module>
main()
File "/home/francois/.p2/pool/plugins/org.python.pydev.core_9.3.0.202203051235/pysrc/runfiles.py", line 97, in main
return pydev_runfiles.main(configuration) # Note: still doesn't return a proper value.
File "/home/francois/.p2/pool/plugins/org.python.pydev.core_9.3.0.202203051235/pysrc/_pydev_runfiles/pydev_runfiles.py", line 874, in main
PydevTestRunner(configuration).run_tests()
File "/home/francois/.p2/pool/plugins/org.python.pydev.core_9.3.0.202203051235/pysrc/_pydev_runfiles/pydev_runfiles.py", line 801, in run_tests
get_django_test_suite_runner()(run_tests).run_tests([])
File "/home/francois/anaconda3/envs/ipaidenv/lib/python3.10/site-packages/django/test/runner.py", line 723, in run_tests
databases = self.get_databases(suite)
File "/home/francois/anaconda3/envs/ipaidenv/lib/python3.10/site-packages/django/test/runner.py", line 702, in get_databases
databases = self._get_databases(suite)
File "/home/francois/anaconda3/envs/ipaidenv/lib/python3.10/site-packages/django/test/runner.py", line 690, in _get_databases
for test in suite:
TypeError: 'NoneType' object is not iterable
ipaidenv is the name of my conda environment, Test is the project name.
I am pretty sure there is something very simple that I didn't do right, but I can't find what, can anyone help?
Many thanks!
Related
I wanted to add the first model to an already working app, and now I can't start it because it always gives AppRegistryNotReady. This does only happen, if my model MailLog is child of models.Model.
from __future__ import unicode_literals
from django.db import models
#class MailLog(models.Model): # like this, it crashes
class MailLog(): # like this, it works
# Field definitions
recipient = models.EmailField()
created = models.DateTimeField(auto_now_add=True)
template = models.CharField(max_length=500)
error = models.TextField(null=True)
def __str__(self):
return self.recipient+" "+self.template+"("+str(self.created)+")"
The error occurs no matter what's inside the class, even if there is only a pass. However, I can import my models in the admin.py, and it crashes when I import from a file I called core.py. That file looks like this:
import boto3
from botocore.exceptions import ClientError
from django.template import loader
from django.conf import settings
from .templates import *
from .models import MailLog
The traceback looks like this
Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/home/niels/anaconda3/envs/app/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
utility.execute()
File "/home/niels/anaconda3/envs/app/lib/python2.7/site-packages/django/core/management/__init__.py", line 316, in execute
settings.INSTALLED_APPS
File "/home/niels/anaconda3/envs/app/lib/python2.7/site-packages/django/conf/__init__.py", line 53, in __getattr__
self._setup(name)
File "/home/niels/anaconda3/envs/app/lib/python2.7/site-packages/django/conf/__init__.py", line 41, in _setup
self._wrapped = Settings(settings_module)
File "/home/niels/anaconda3/envs/app/lib/python2.7/site-packages/django/conf/__init__.py", line 97, in __init__
mod = importlib.import_module(self.SETTINGS_MODULE)
File "/home/niels/anaconda3/envs/app/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/niels/Dokumente/jobapp/deploy/backend/settings.py", line 255, in <module>
django.setup()
File "/home/niels/anaconda3/envs/app/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/niels/anaconda3/envs/app/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/niels/anaconda3/envs/app/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/home/niels/anaconda3/envs/app/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/niels/Dokumente/jobapp/deploy/ses_mail/__init__.py", line 1, in <module>
from .core import send
File "/home/niels/Dokumente/jobapp/deploy/ses_mail/core.py", line 7, in <module>
from .admin import MailLog
File "/home/niels/Dokumente/jobapp/deploy/ses_mail/admin.py", line 2, in <module>
from .models import *
File "/home/niels/Dokumente/jobapp/deploy/ses_mail/models.py", line 6, in <module>
class MailLog(models.Model):
File "/home/niels/anaconda3/envs/app/lib/python2.7/site-packages/django/db/models/base.py", line 105, in __new__
app_config = apps.get_containing_app_config(module)
File "/home/niels/anaconda3/envs/app/lib/python2.7/site-packages/django/apps/registry.py", line 237, in get_containing_app_config
self.check_apps_ready()
File "/home/niels/anaconda3/envs/app/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.
You should not be importing Django models in your app's __init__ (or causing them to be imported by importing from core. If you use an empty __init__.py it should stop the error.
I have upgraded django version from 1.8 into 1.9 and django rest framework to 3.3.3. I am getting this exception:
django.core.exceptions.AppRegistryNotReady: Apps aren't loaded yet.
I have tried as follows but exception is still there.
#__init__.py
default_app_config = 'panel.apps.PanelConfig'
And also
#apps.py
from django.apps import AppConfig
class PanelConfig(AppConfig):
name = 'panel'
def ready(self):
from panel import receivers
for all apps and added these to installed apps
'api.apps.ApiConfig',
'billing.apps.ApiConfig',
'incoming.apps.IncomingConfig',
'outgoing.apps.OutgoingConfig',
'panel.apps.PanelConfig',
This is my full traceback:
Unhandled exception in thread started by <function wrapper at 0x7f3eec09c7d0>
Traceback (most recent call last):
File "/home/sparrow/virtualenvs/bishnu/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/sparrow/virtualenvs/bishnu/local/lib/python2.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/home/sparrow/virtualenvs/bishnu/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 249, in raise_last_exception
six.reraise(*_exception)
File "/home/sparrow/virtualenvs/bishnu/local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/sparrow/virtualenvs/bishnu/local/lib/python2.7/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/sparrow/virtualenvs/bishnu/local/lib/python2.7/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/sparrow/virtualenvs/bishnu/local/lib/python2.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/sparrow/virtualenvs/bishnu/local/lib/python2.7/site-packages/admin_tools/dashboard/__init__.py", line 1, in <module>
from admin_tools.dashboard.dashboards import *
File "/home/sparrow/virtualenvs/bishnu/local/lib/python2.7/site-packages/admin_tools/dashboard/dashboards.py", line 13, in <module>
from django.contrib.contenttypes.models import ContentType
File "/home/sparrow/virtualenvs/bishnu/local/lib/python2.7/site-packages/django/contrib/contenttypes/models.py", line 161, in <module>
class ContentType(models.Model):
File "/home/sparrow/virtualenvs/bishnu/local/lib/python2.7/site-packages/django/db/models/base.py", line 94, in __new__
app_config = apps.get_containing_app_config(module)
File "/home/sparrow/virtualenvs/bishnu/local/lib/python2.7/site-packages/django/apps/registry.py", line 239, in get_containing_app_config
self.check_apps_ready()
File "/home/sparrow/virtualenvs/bishnu/local/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.
Exception is still there ? What is the problem ? I am not getting ?
The traceback shows you that the problem is occuring in admin_tools.
from admin_tools.dashboard.dashboards import *
File "/home/sparrow/virtualenvs/bishnu/local/lib/python2.7/site-packages/admin_tools/dashboard/dashboards.py", line 13, in <module>
from django.contrib.contenttypes.models import ContentType
It looks like it has been fixed, so try upgrading to the latest release, currently 0.7.2.
I have the following in xsd_messages/forms.py
import xsd_training.models
class UpdateRequestForm(forms.Form):
lesson = forms.ModelChoiceField(
queryset=xsd_training.models.Lesson.objects.all())
This gives the error:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/will/env/xSACdb/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 385, in execute_from_command_line
utility.execute()
File "/home/will/env/xSACdb/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 354, in execute
django.setup()
File "/home/will/env/xSACdb/local/lib/python2.7/site-packages/django/__init__.py", line 21, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/will/env/xSACdb/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
app_config.import_models(all_models)
File "/home/will/env/xSACdb/local/lib/python2.7/site-packages/django/apps/config.py", line 202, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/will/local/xSACdb/xsd_members/models.py", line 6, in <module>
from xsd_training.models import PerformedLesson
File "/home/will/local/xSACdb/xsd_training/models.py", line 8, in <module>
import xsd_messages.views
File "/home/will/local/xSACdb/xsd_messages/views.py", line 15, in <module>
from xsd_messages.forms import MailingComposeForm, UpdateRequestForm
File "/home/will/local/xSACdb/xsd_messages/forms.py", line 14, in <module>
class UpdateRequestForm(forms.Form):
File "/home/will/local/xSACdb/xsd_messages/forms.py", line 26, in UpdateRequestForm
queryset=xsd_training.models.Lesson.objects.all())
AttributeError: 'module' object has no attribute 'models'
However models does exist as proven using the shell:
>>> import xsd_training.models
>>> xsd_training.models.Lesson.objects.all()
[<Lesson...
What's going on?
You've got a circular reference: members.models imports training.models, which imports messages.views, which imports mesages.forms, which imports training.models... that circularity can't be resolved, so Python reports an error.
You need to break that chain. Without seeing the code I can't help you more, but it is deeply suspicious that a models file imports a views file: that really shouldn't happen.
Moved import xsd_messages.views in xsd_training.models to inside a function rather than at the top of the file.
I followed the steps here https://developers.google.com/cloud-sql/docs/django and it ran well with django 1.3.1. Now up to Django 1.4 and gives a funny stack trace. I would paste the relevant part of the message here
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/dumb906/woody/py/mdlr/django/core/management/__init__.py", line 443, in execute_from_command_line
utility.execute()
File "/home/dumb906/woody/py/mdlr/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/dumb906/woody/py/mdlr/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/dumb906/woody/py/mdlr/django/core/management/__init__.py", line 69, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/home/dumb906/woody/py/mdlr/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/dumb906/woody/py/mdlr/django/core/management/commands/test.py", line 7, in <module>
from django.test.utils import get_runner
File "/home/dumb906/woody/py/mdlr/django/test/__init__.py", line 5, in <module>
from django.test.client import Client, RequestFactory
File "/home/dumb906/woody/py/mdlr/django/test/client.py", line 21, in <module>
from django.test import signals
File "/home/dumb906/woody/py/mdlr/django/test/signals.py", line 2, in <module>
from django.db import connections
File "/home/dumb906/woody/py/mdlr/django/db/__init__.py", line 40, in <module>
backend = load_backend(connection.settings_dict['ENGINE'])
File "/home/dumb906/woody/py/mdlr/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/home/dumb906/woody/py/mdlr/django/db/utils.py", line 92, in __getitem__
backend = load_backend(db['ENGINE'])
File "/home/dumb906/woody/py/mdlr/django/db/utils.py", line 44, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'google.appengine.ext.django.backends.rdbms' isn't an available database backend.
Try using django.db.backends.XXX, where XXX is one of:
'dummy', 'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'
Error was: cannot import name Thing2Literal
Any help? Some one said it needs to be compiled http://django-irc-logs.com/2012/mar/27/ ?
I had the same issue. Since the problem is with importing Thing2Literal that is used by adapt_datetime_with_timezone_support function from django/db/backends/mysql/base.py and according to this:
https://code.djangoproject.com/changeset/17596/django/trunk/django/db/backends/mysql/base.py this is important only to datetime objects that bypass the model layer and are used with raw sql. So i decided it is not important for me and I messed a bit my django/db/backends/mysql/base.py: comment out code that causes trouble (import of Thing2Literal, adapt_datetime_with_timezone_support function and line 83 where the function is called)
Of course I upload my django 1.4 customized that way to appengine together with my project and it works.
I would appreciate feedback from those who understand django internals better, whether what i've done is ok assuming i don't use raw sql at all.
As you can see in the documentation you've linked, Google App Engine support only Django up to version 1.3 (actually 1.3.1).
Whenever I try to run a command like python manage.py syncdb, I get the following error:
Traceback (most recent call last):
File "manage.py", line 11, in
execute_manager(settings)
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/core/management/__init__.py", line 438, in execute_manager
utility.execute()
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/core/management/__init__.py", line 379, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/core/management/__init__.py", line 261, in fetch_command
klass = load_command_class(app_name, subcommand)
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/core/management/__init__.py", line 67, in load_command_class
module = import_module('%s.management.commands.%s' % (app_name, name))
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/south/management/commands/__init__.py", line 10, in
import django.template.loaders.app_directories
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/template/loaders/app_directories.py", line 21, in
mod = import_module(app)
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/contrib/admin/__init__.py", line 1, in
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/contrib/admin/helpers.py", line 1, in
from django import forms
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/forms/__init__.py", line 17, in
from models import *
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/forms/models.py", line 6, in
from django.db import connections
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/db/__init__.py", line 77, in
connection = connections[DEFAULT_DB_ALIAS]
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/db/utils.py", line 91, in __getitem__
backend = load_backend(db['ENGINE'])
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/db/utils.py", line 32, in load_backend
return import_module('.base', backend_name)
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/damon/Workspace/django-projects/acm-cie/env/lib/python2.6/site-packages/django/db/backends/oracle/base.py", line 24, in
raise ImproperlyConfigured("Error loading cx_Oracle module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading cx_Oracle module: libclntsh.so.11.1: cannot open shared object file: No such file or directory
Is this resolvable on Ubuntu?
You need to install both cx_Oracle and an Oracle Client.
cx_Oracle can be found here.
An appropriate Oracle Client can be found here.
You will also need to set the LD_LIBRARY_PATH variable before you start your application. This can usually be done (for example):
export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
Now you should be able to get past the cx_Oracle error message.
First things first - is this actually a Django problem, or just a cx_Oracle problem? Is cx_Oracle installed correctly? Can you connect to your Oracle database in a Python shell session?
import cx_Oracle
conn = cx_Oracle.connect('/') # user/password#dsn
cursor = conn.cursor()
If this doesn't raise an exception, you have connected successfully.
try easy_install cx_Oracle, it will compile cx_Oracle module from source