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'
Related
when i want do an import django i get an error
ubuntu 18.04 with a reverse proxy (nginx) and uwsgi (mode emperor actived) in virtual env with python 3.6.3 and latest django 2.2.5
test.py:
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.settings")
import django
print("test")'
when i run python3 test.py i get :
(venv) :~/testproject/testproject/testproject$ python3.6 test.py
Traceback (most recent call last):
File "test.py", line 3, in <module>
from django.http import HttpResponse
File "/home/lukas/testproject/venv/lib/python3.6/site-packages/django/__init__.py", line 1, in <module>
from django.utils.version import get_version
File "/home/lukas/testproject/venv/lib/python3.6/site-packages/django/utils/version.py", line 4, in <module>
import subprocess
File "/usr/lib/python3.6/subprocess.py", line 140, in <module>
import threading
File "/usr/lib/python3.6/threading.py", line 7, in <module>
from traceback import format_exc as _format_exc
File "/usr/lib/python3.6/traceback.py", line 5, in <module>
import linecache
File "/home/lukas/testproject/venv/lib/python3.6/linecache.py", line 11, in <module>
import tokenize
File "/home/lukas/testproject/venv/lib/python3.6/tokenize.py", line 35, in <module>
from token import *
File "/home/lukas/testproject/testproject/testproject/token.py", line 1, in <module>
from django.contrib.auth.tokens import PasswordResetTokenGenerator
File "/home/lukas/testproject/venv/lib/python3.6/site-packages/django/contrib/auth/__init__.py", line 4, in <module>
from django.apps import apps as django_apps
File "/home/lukas/testproject/venv/lib/python3.6/site-packages/django/apps/__init__.py", line 2, in <module>
from .registry import apps
File "/home/lukas/testproject/venv/lib/python3.6/site-packages/django/apps/registry.py", line 426, in <module>
apps = Apps(installed_apps=None)
File "/home/lukas/testproject/venv/lib/python3.6/site-packages/django/apps/registry.py", line 46, in __init__
self.ready_event = threading.Event()
AttributeError: module 'threading' has no attribute 'Event'
i have the same error on python3 shell when i do import django whereas django have been installed with pip3 install and production mode is ok and developement mode with runserver is ok too.
can you help me, i m lost...
Do you have, by any chance, a token module in you django project?
As the python path is modified to prefer local modules rather than other pre-defined modules, the from token import * instruction will import from your module instead of the python lib one.
Try renaming your local modules to avoid collision with builtin python modules.
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 made a registration system with Django using celery, redis. It was working fine till today. But getting this error 'Redis is not install' when try to register a new user. I was trying to check packages installed using pip and getting this.
Traceback (most recent call last):
File "/home/chhuti/projects/venv/chhuti/bin/pip", line 7, in <module>
from pip import main
File "/home/chhuti/projects/venv/chhuti/lib/python3.6/site-
packages/pip/__init__.py", line 26, in <module>
from pip.utils import get_installed_distributions, get_prog
File "/home/chhuti/projects/venv/chhuti/lib/python3.6/site-
packages/pip/utils/__init__.py", line 23, in <module>
from pip.locations import (
File "/home/chhuti/projects/venv/chhuti/lib/python3.6/site-
packages/pip/locations.py", line 9, in <module>
from distutils import sysconfig
File
"/home/chhuti/projects/venv/chhuti/lib/python3.6/distutils/__init__.py", line 25, in <module>
from distutils import dist, sysconfig
ImportError: cannot import name 'dist'
I am using
pip version 9.0.2,
Python version 3.6.3
Django 1.11
Have been stuck here for a long time now, couldn't solve it.
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.
I installed subversion, which seemed to install Python25, which my computer won't let me erase, or even recognize as a program on the control panel. I copied my Python27 Python.py file into the Python 25 folder to replace Python.py (the Python 25 version), and got my command prompt to run Python 27 (even though I had specified the Python 27 folder, it insisted on running Python 25). I copied the Django trunk into the site-packages of Django 27 and Django 25. Import Django works in Python, but now I'm getting this error:
C:\Windows\system32>cd C:\Users\Susan\Documents\practice
C:\Users\Susan\Documents\practice>django-admin.py startproject mysite
Traceback (most recent call last):
File "C:\csvn\Python25\django-admin.py", line 2, in <module>
from django.core import management
File "C:\csvn\Python25\lib\site-packages\django\core\management\__init__.py",
line 7, in <module>
from django.core.management.base import BaseCommand, CommandError, handle_de
fault_options
File "C:\csvn\Python25\lib\site-packages\django\core\management\base.py", line
14, in <module>
from django.utils.encoding import smart_str
File "C:\csvn\Python25\lib\site-packages\django\utils\encoding.py", line 2, in
<module>
import urllib
File "C:\csvn\Python25\lib\urllib.py", line 26, in <module>
import socket
File "C:\csvn\Python25\lib\socket.py", line 45, in <module>
import _socket
ImportError: Module use of python25.dll conflicts with this version of Python.
Thanks in advance.
Oh, and this is my environment path variable: C:\Program Files\SSH Communications Security\SSH Secure Shell;C:\Python27;C\Python27\scripts;C:\Python27\Lib\site-packages\django\bin\
And this is my python variable: C:\Python27;C\Python27\scripts;C:\Python27\Lib\site-packages\django\bin\
EDIT: realized that USER path wasn't the same as System path. Made them both the same, now receiving this message:
C:\Users\Susan\Documents\practice>django-admin.py startproject mysite
Traceback (most recent call last):
File "C:\Python27\Lib\site-packages\django\django\bin\django-admin.py", line 2
, in <module>
from django.core import management
File "C:\csvn\Python25\lib\site-packages\django\core\management\__init__.py",
line 7, in <module>
from django.core.management.base import BaseCommand, CommandError, handle_de
fault_options
File "C:\csvn\Python25\lib\site-packages\django\core\management\base.py", line
14, in <module>
from django.utils.encoding import smart_str
File "C:\csvn\Python25\lib\site-packages\django\utils\encoding.py", line 2, in
<module>
import urllib
File "C:\csvn\Python25\lib\urllib.py", line 26, in <module>
import socket
File "C:\csvn\Python25\lib\socket.py", line 45, in <module>
import _socket
ImportError: DLL load failed: The specified module could not be found.
Why does it keep trying to use Python25?
I would un-install Python 2.7 and 2.5 from your machine and re-inistall Python 2.7. You'll have to have a working Python install before you can think about installing Django.
After that's working, I would recommend installing virtualenv and Justin Driscoll's virtualenv helper for Windows.
Virtualenv allows you to create different Python runtimes so you don't have to install modules directly into the system Python Path. Installing virtualenv gets you pip, which you can use to install modules like Django, into your virtualenv's site-packages folder.