I am trying out the django cms. I have now tried the recipe described here: http://docs.django-cms.org/en/support-3.0.x/introduction/install_from_scratch.html very carefully, but towards the end of the installer run it fails with an exception:
...
raise exceptions.UnknownMigration(self, sys.exc_info())
south.exceptions.UnknownMigration: Migration 'auth:0001_initial' probably doesn't exist.
Traceback (most recent call last):
File "/tmp/munin-cloud/venv/local/lib/python2.7/site-packages/south/migration/base.py", line 313, in migration
migration = __import__(full_name, {}, {}, ['Migration'])
File "/tmp/munin-cloud/venv/local/lib/python2.7/site-packages/django/contrib/auth/migrations/0001_initial.py", line 5, in <module>
from django.db import models, migrations
File "/tmp/munin-cloud/venv/local/lib/python2.7/site-packages/django/db/migrations/__init__.py", line 2, in <module>
from .operations import * # NOQA
File "/tmp/munin-cloud/venv/local/lib/python2.7/site-packages/django/db/migrations/operations/__init__.py", line 1, in <module>
from .models import (CreateModel, DeleteModel, AlterModelTable,
File "/tmp/munin-cloud/venv/local/lib/python2.7/site-packages/django/db/migrations/operations/models.py", line 4, in <module>
from django.db.models.options import normalize_together
ImportError: cannot import name normalize_together
Traceback (most recent call last):
File "/tmp/munin-cloud/venv/bin/djangocms", line 11, in <module>
sys.exit(execute())
File "/tmp/munin-cloud/venv/local/lib/python2.7/site-packages/djangocms_installer/main.py", line 31, in execute
django.setup_database(config_data)
File "/tmp/munin-cloud/venv/local/lib/python2.7/site-packages/djangocms_installer/django/__init__.py", line 325, in setup_database
"manage.py", "migrate", "--fake"], env=env)
File "/usr/lib/python2.7/subprocess.py", line 540, in check_call
raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError:
Command '['/tmp/munin-cloud/venv/bin/python', '-W', 'ignore', 'manage.py', 'migrate', '--fake']'
returned non-zero exit status 1
When running manage.pg syncdb it reports that some of the tables have been synced, and some are not synced - use migrations. When I then run manage.py migrate I get the same exception again.
I am on Ubuntu 14.04 - if that matters.
I mixed up the django version in the current virtual environment and the django version configured during the django-cms install process. When I ensured that I had Django 1.6 installed and entered 1.6 during django-cms configuration it worked.
Related
Usage: python -m flask run [OPTIONS]
Try python -m flask run --help for help.
Error: While importing 'app', an ImportError was raised:
Traceback (most recent call last):
File "C:\Users\Dreams Reality\AppData\Roaming\Python\Python38\site-packages\flask\cli.py", line 218, in locate_app
__import__(module_name)
File "C:\Users\Dreams Reality\Desktop\api\app.py", line 2, in <module>
from flask_restplus import Api, Resource, fields
File "C:\Users\Dreams Reality\AppData\Local\Programs\Python\Python38\lib\site-packages\flask_restplus\__init__.py", line 4, in <module>
from . import fields, reqparse, apidoc, inputs, cors
File "C:\Users\Dreams Reality\AppData\Local\Programs\Python\Python38\lib\site-packages\flask_restplus\fields.py", line 17, in <module>
from werkzeug import cached_property
ImportError: cannot import name 'cached_property' from 'werkzeug' (C:\Users\Dreams Reality\AppData\Local\Programs\Python\Python38\lib\site-packages\werkzeug\__init__.py)
I tried running my flask project using python -m flask run
I expected to take a good look at my project on localhost,
And am getting this:
Try python -m flask run --help for help.
Error: While importing 'app', an ImportError was raised:
Traceback (most recent call last):
File "C:\Users\Dreams Reality\AppData\Roaming\Python\Python38\site-packages\flask\cli.py", line 218, in locate_app
__import__(module_name)
File "C:\Users\Dreams Reality\Desktop\api\app.py", line 2, in <module>
from flask_restplus import Api, Resource, fields
File "C:\Users\Dreams Reality\AppData\Local\Programs\Python\Python38\lib\site-packages\flask_restplus\__init__.py", line 4, in <module>
from . import fields, reqparse, apidoc, inputs, cors
File "C:\Users\Dreams Reality\AppData\Local\Programs\Python\Python38\lib\site-packages\flask_restplus\fields.py", line 17, in <module>
from werkzeug import cached_property
ImportError: cannot import name 'cached_property' from 'werkzeug' (C:\Users\Dreams Reality\AppData\Local\Programs\Python\Python38\lib\site-packages\werkzeug\__init__.py)
it seems like some of your packages aren't compatible with each other.
try checking your dependencies
flask-restplus does not appear to have been updated for several years[1]. Since then, Werkzeug moved cached_property[2].
In your position, I'd drop flask-restplus and either choose an actively maintained rest package for flask, or roll your own.
[1] https://github.com/noirbizarre/flask-restplus
[2] https://werkzeug.palletsprojects.com/en/1.0.x/changes/
I want to add info in database using django-seed.
seed.py
from django_seed import Seed
from models import Employee
seeder = Seed.seeder()
seeder.add_entity(Employee, 5)
inserted_pks = seeder.execute()
When I try to start command: python3 seed.py
I've got this error:
Traceback (most recent call last):
File "seed.py", line 2, in <module>
from models import Employee
File "/home/kaucap/test/myproject/app_worker/models.py", line 4, in <module>
class Employee(models.Model):
File "/home/kaucap/test/venv/lib/python3.8/site-packages/django/db/models/base.py", line 127, in __new__
app_config = apps.get_containing_app_config(module)
File "/home/kaucap/test/venv/lib/python3.8/site-packages/django/apps/registry.py", line 260, in get_containing_app_config
self.check_apps_ready()
File "/home/kaucap/test/venv/lib/python3.8/site-packages/django/apps/registry.py", line 137, in check_apps_ready
settings.INSTALLED_APPS
File "/home/kaucap/test/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 87, in __getattr__
self._setup(name)
File "/home/kaucap/test/venv/lib/python3.8/site-packages/django/conf/__init__.py", line 67, in _setup
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Requested setting INSTALLED_APPS, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
Can anyone explain why I have this error and how I can fix it?
python3 seed.py started python without Django settings.
if you are want to start seed.py in Django "environment",
in your django-pproject folder:
python3 manage.py shell
Django shell starts, and in shell:
import seed.py
If you see the same error - you have not created any Django project yet.
Started having issues running Django. Install runs without error, however when I check the version packages that show "already satisified" are not found.
I've removed my .local and re-installed files, no change.
% pip3 install /path/.../Django-3.0b1/ --user
Processing /path/.../Django-3.0b1
Requirement already satisfied: pytz in /usr/lib/python3.6/site-packages (from Django==3.0b1) (2018.5)
Requirement already satisfied: sqlparse in /path/.../.local/lib/python3.6/site-packages (from Django==3.0b1) (0.3.0)
Requirement already satisfied: asgiref in path/.../.local/lib/python3.6/site-packages (from Django==3.0b1) (3.2.3)
Installing collected packages: Django
Running setup.py install for Django ... done
Successfully installed Django-3.0b1
% python3 -m django --version
Traceback (most recent call last):
File "/path/.../python/3.7.3b/lib/python3.7/runpy.py", line 193, in
_run_module_as_main "__main__", mod_spec)
File "/path/.../python/3.7.3b/lib/python3.7/runpy.py", line 85, in _run_code exec(code, run_globals)
File "/path/.../Django-3.0b1/django/__main__.py", line 6, in <module> from django.core import management
File "/path/.../Django-3.0b1/django/core/management/__init__.py", line 14, in <module> from django.core.management.base import (
File "/path/.../Django-3.0b1/django/core/management/base.py", line 11, in <module> from django.core import checks
File "/path/.../Django-3.0b1/django/core/checks/__init__.py", line 9, in <module> import django.core.checks.database # NOQA isort:skip
File "/path/.../Django-3.0b1/django/core/checks/database.py", line 1, in <module> from django.db import connections
File "/path/.../Django-3.0b1/django/db/__init__.py", line 2, in <module> from django.db.utils import (
File "/path/.../Django-3.0b1/django/db/utils.py", line 5, in <module> from asgiref.local import Local
ModuleNotFoundError: No module named 'asgiref'
After upgrading my Ubuntu desktop to 18.04 from 16.04, the django's virtualenv refuses to start:
(.djangoenv) mw#desktop:~/theapp$ python manage.py runserver
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
File "/home/mw/.djangoenv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 10, in <module>
from django.apps import apps
File "/home/mw/.djangoenv/local/lib/python2.7/site-packages/django/apps/__init__.py", line 1, in <module>
from .config import AppConfig # NOQA
File "/home/mw/.djangoenv/local/lib/python2.7/site-packages/django/apps/config.py", line 4, in <module>
from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
File "/home/mw/.djangoenv/local/lib/python2.7/site-packages/django/core/exceptions.py", line 5, in <module>
from django.utils.encoding import force_text
File "/home/mw/.djangoenv/local/lib/python2.7/site-packages/django/utils/encoding.py", line 10, in <module>
from django.utils.functional import Promise
File "/home/mw/.djangoenv/local/lib/python2.7/site-packages/django/utils/functional.py", line 1, in <module>
import copy
File "/usr/lib/python2.7/copy.py", line 52, in <module>
import weakref
File "/usr/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
On the djangoenv and outside it
$ python --version :
`Python 2.7.12`
Hoping to resolve the issue, I also install Python 2.7.16 on the desktop, so I get:
$ python2.7 --version
Python 2.7.16
Also when I try to install new virtualenv, I get the same error:
$ virtualenv .blaenv
Running virtualenv with interpreter /home/mw/.djangoenv/bin/python2
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/virtualenv.py", line 21, in <module>
import logging
File "/usr/lib/python2.7/logging/__init__.py", line 26, in <module>
import sys, os, time, cStringIO, traceback, warnings, weakref, collections
File "/usr/lib/python2.7/weakref.py", line 14, in <module>
from _weakref import (
ImportError: cannot import name _remove_dead_weakref
Answers to the same error in other contexts did not help and my search led to no more clues.
So really appreciate your hints.
As per https://askubuntu.com/questions/981663/python2-7-broken-by-weakref-import-error-please-help you probably need to recreate your virtualenv. I suspect your problem here is that you need to deactivate your current env before you try to make the new one, in order to ensure that your system python2 interpreter is the one running the virtualenv command.
I did the steps at the tutorial " http://django-mptt.github.com/django-mptt/tutorial.html "
but it still give me the import error , I double check the code for the mptt and found the class MPTTMODEL exist in the mptt>model file
Validating models...
Unhandled exception in thread started by <bound method Command.inner_run of <django.contrib.staticfiles.management.commands.runserver.Command object at 0x1ec4710>>
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/core/management/commands/runserver.py", line 91, in inner_run
self.validate(display_num_errors=True)
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/core/management/base.py", line 266, in validate
num_errors = get_validation_errors(s, app)
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/core/management/validation.py", line 30, in get_validation_errors
for (app_name, error) in get_app_errors().items():
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/db/models/loading.py", line 158, in get_app_errors
self._populate()
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/db/models/loading.py", line 67, in _populate
self.load_app(app_name)
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/db/models/loading.py", line 88, in load_app
models = import_module('.models', app_name)
File "/usr/local/lib/python2.7/dist-packages/Django-1.4-py2.7.egg/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/home/kareemhashem/espace/sharek/core/models.py", line 12, in <module>
from mptt.models import MPTTModel, TreeForeignKey
ImportError: cannot import name MPTTModel
One thing you could try: Go to the console and type: python (to get the python console) and then enter: from mptt.models import MPTTModel
If this gives you an error than mptt is not correctly installed.
If you are using pip you could easily do: pip install django-mptt or you might try pip install django-mptt --upgrade to update your installation. It might be that your installation did not succeeded.
If you are not using pip or virtualenv I highly recommend it. The start is a bit tough, but it is worse to install it. See these resources to get started: 1, 2
If you have successfully installed mptt and you still cannot import it, the folder where you placed mptt into is probably not accessible to python. Therefore add the path where mptt lives to your PYTHONPATH. See this thread how to do it.