django not able to find git - django

I'm trying to get Django development started on my Windows 7 partition and I'm finding that whenever I run a Django command I get:
'git' is not recognized as an internal or external command,
operable program or batch file.
Often 3-4 times in a row but then the command seems to execute fine. While it doesn't seem to be affecting the execution of the commands, I don't like having errors thrown every time I do something, makes me nervous (and there's very possibly something I'm missing that's going wrong). I tried adding git to my environment variables but it didn't seem to work, here is the current PATH value.
;C:\Chocolatey\bin;C:\tools\mysql\current\bin;C:\Program Files (x86)\Git\bin
Any additional suggestions to try are welcome. I'm using Windows 7 and the most recent version of Python, Django, and Git (just downloaded them today).
EDIT: I ran the commands again in response to some of your comments (thanks for those btw). Here's the output to python manage.py runserver
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\django\db\backends\mysql\base.py", line 14, in
import MySQLdb as Database
ImportError: No module named 'MySQLdb'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python33\lib\site-packages\django\core\management\__init__.py", line 416, in execute_from_command_line
utility.execute()
File "C:\Python33\lib\site-packages\django\core\management\__init__.py", line 408, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python33\lib\site-packages\django\core\management\base.py", line 244, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python33\lib\site-packages\django\core\management\base.py", line 286, in execute
translation.activate('en-us')
File "C:\Python33\lib\site-packages\django\utils\translation\__init__.py", line 142, in activate
return _trans.activate(language)
File "C:\Python33\lib\site-packages\django\utils\translation\trans_real.py", line 218, in activate
_active.value = translation(language)
File "C:\Python33\lib\site-packages\django\utils\translation\trans_real.py", line 201, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "C:\Python33\lib\site-packages\django\utils\translation\trans_real.py", line 183, in _fetch
app = import_module(appname)
File "C:\Python33\lib\importlib\__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1586, in _gcd_import
File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
File "<frozen importlib._bootstrap>", line 1024, in load_module
File "<frozen importlib._bootstrap>", line 1005, in load_module
File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
File "<frozen importlib._bootstrap>", line 870, in _load_module
File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
File "C:\Python33\lib\site-packages\django\contrib\admin\__init__.py", line 7, in <module>
from django.contrib.admin.sites import AdminSite, site
File "C:\Python33\lib\site-packages\django\contrib\admin\sites.py", line 4, in <module>
from django.contrib.admin.forms import AdminAuthenticationForm
File "C:\Python33\lib\site-packages\django\contrib\admin\forms.py", line 6, in <module>
from django.contrib.auth.forms import AuthenticationForm
File "C:\Python33\lib\site-packages\django\contrib\auth\forms.py", line 16, in <module>
from django.contrib.auth.models import User
File "C:\Python33\lib\site-packages\django\contrib\auth\models.py", line 40, in <module>
class Permission(models.Model):
File "C:\Python33\lib\site-packages\django\db\models\base.py", line 108, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "C:\Python33\lib\site-packages\django\db\models\base.py", line 291, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Python33\lib\site-packages\django\db\models\options.py", line 141, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Python33\lib\site-packages\django\db\__init__.py", line 39, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Python33\lib\site-packages\django\db\utils.py", line 192, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Python33\lib\site-packages\django\db\utils.py", line 107, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Python33\lib\importlib\__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Python33\lib\site-packages\django\db\backends\mysql\base.py", line 17, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
And here's the output to python manage.py syncdb
fatal: Not a git repository (or any of the parent directories): .git
fatal: Not a git repository (or any of the parent directories): .git
Traceback (most recent call last):
File "C:\Python33\lib\site-packages\django\db\backends\mysql\base.py", line 14, in <module>
import MySQLdb as Database
ImportError: No module named 'MySQLdb'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python33\lib\site-packages\django\core\management\__init__.py", line 416, in execute_from_command_line
utility.execute()
File "C:\Python33\lib\site-packages\django\core\management\__init__.py", line 408, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python33\lib\site-packages\django\core\management\base.py", line 244, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python33\lib\site-packages\django\core\management\base.py", line 286, in execute
translation.activate('en-us')
File "C:\Python33\lib\site-packages\django\utils\translation\__init__.py", line 142, in activate
return _trans.activate(language)
File "C:\Python33\lib\site-packages\django\utils\translation\trans_real.py", line 218, in activate
_active.value = translation(language)
File "C:\Python33\lib\site-packages\django\utils\translation\trans_real.py", line 201, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "C:\Python33\lib\site-packages\django\utils\translation\trans_real.py", line 183, in _fetch
app = import_module(appname)
File "C:\Python33\lib\importlib\__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1586, in _gcd_import
File "<frozen importlib._bootstrap>", line 1567, in _find_and_load
File "<frozen importlib._bootstrap>", line 1534, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 586, in _check_name_wrapper
File "<frozen importlib._bootstrap>", line 1024, in load_module
File "<frozen importlib._bootstrap>", line 1005, in load_module
File "<frozen importlib._bootstrap>", line 562, in module_for_loader_wrapper
File "<frozen importlib._bootstrap>", line 870, in _load_module
File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
File "C:\Python33\lib\site-packages\django\contrib\admin\__init__.py", line 7, in <module>
from django.contrib.admin.sites import AdminSite, site
File "C:\Python33\lib\site-packages\django\contrib\admin\sites.py", line 4, in <module>
from django.contrib.admin.forms import AdminAuthenticationForm
File "C:\Python33\lib\site-packages\django\contrib\admin\forms.py", line 6, in <module>
from django.contrib.auth.forms import AuthenticationForm
File "C:\Python33\lib\site-packages\django\contrib\auth\forms.py", line 16, in <module>
from django.contrib.auth.models import User
File "C:\Python33\lib\site-packages\django\contrib\auth\models.py", line 40, in <module>
class Permission(models.Model):
File "C:\Python33\lib\site-packages\django\db\models\base.py", line 108, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "C:\Python33\lib\site-packages\django\db\models\base.py", line 291, in add_to_class
value.contribute_to_class(cls, name)
File "C:\Python33\lib\site-packages\django\db\models\options.py", line 141, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "C:\Python33\lib\site-packages\django\db\__init__.py", line 39, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "C:\Python33\lib\site-packages\django\db\utils.py", line 192, in __getitem__
backend = load_backend(db['ENGINE'])
File "C:\Python33\lib\site-packages\django\db\utils.py", line 107, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Python33\lib\importlib\__init__.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "C:\Python33\lib\site-packages\django\db\backends\mysql\base.py", line 17, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: No module named 'MySQLdb'
Seems to be a result of missing MySQLdb. Does anyone have a link to this module? I can't find anything on Pypi called this exactly, I'm not sure which one it's looking for.

is it possible that you overwrote your "manage.py" with something which tries to start git? Your manage.py should look like this:
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "yourapp.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)
Or do you have a "git" commant in your settings.py?
EDIT after your error logs:
Did you install the MySQL-python package (see docs at https://docs.djangoproject.com/en/dev/topics/install/#get-your-database-running) AND MySQLdb (see https://docs.djangoproject.com/en/dev/ref/databases/#mysqldb)? Both are required when using MySQL.
If yes, do you get the same results when switching to a sqlite database?

Related

django-main-thread error when running manage.py runserver

I've made some changes to my code while trying to deploy my django app on digital ocean, and now when I try to test my code in my local server, I get this error:
(my_chaburah) ~/Desktop/Code/my_chaburah (main)
$ python3 manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 24, in <module>
import psycopg2 as Database
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/psycopg2/__init__.py", line 51, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: dlopen(/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so, 0x0002): Library not loaded: '/opt/homebrew/opt/postgresql/lib/libpq.5.dylib'
Referenced from: '/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so'
Reason: tried: '/opt/homebrew/opt/postgresql/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib' (no such file), '/opt/homebrew/Cellar/postgresql#14/14.5_5/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib' (no such file)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/opt/homebrew/Cellar/python#3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 980, in _bootstrap_inner
self.run()
File "/opt/homebrew/Cellar/python#3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 917, in run
self._target(*self._args, **self._kwargs)
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
autoreload.raise_last_exception()
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/core/management/__init__.py", line 398, in execute
autoreload.check_errors(django.setup)()
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/apps/registry.py", line 116, in populate
app_config.import_models()
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/apps/config.py", line 304, in import_models
self.models_module = import_module(models_module_name)
File "/opt/homebrew/Cellar/python#3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/contrib/auth/models.py", line 3, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/contrib/auth/base_user.py", line 49, in <module>
class AbstractBaseUser(models.Model):
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/db/models/base.py", line 141, in __new__
new_class.add_to_class("_meta", Options(meta, app_label))
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/db/models/base.py", line 369, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/db/models/options.py", line 235, in contribute_to_class
self.db_table, connection.ops.max_name_length()
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/utils/connection.py", line 15, in __getattr__
return getattr(self._connections[self._alias], item)
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/utils/connection.py", line 62, in __getitem__
conn = self.create_connection(alias)
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/db/utils.py", line 208, in create_connection
backend = load_backend(db["ENGINE"])
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/db/utils.py", line 113, in load_backend
return import_module("%s.base" % backend_name)
File "/opt/homebrew/Cellar/python#3.9/3.9.15/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 28, in <module>
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so, 0x0002): Library not loaded: '/opt/homebrew/opt/postgresql/lib/libpq.5.dylib'
Referenced from: '/Users/almoni/.local/share/virtualenvs/my_chaburah-AiCSV-sC/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so'
Reason: tried: '/opt/homebrew/opt/postgresql/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib' (no such file), '/opt/homebrew/Cellar/postgresql#14/14.5_5/lib/libpq.5.dylib' (no such file), '/usr/local/lib/libpq.5.dylib' (no such file), '/usr/lib/libpq.5.dylib' (no such file)
I have no idea what I'm looking at -- I've never seen this kind of error before. No idea where to even start. Because of my confusion I'm not sure what parts of my code I should post to help elaborate. Just want to get my app working again before I try to deploy.
I'm just guessing but I assume it has something to do with virtual environments or pip installations, although I'm concerened it's because I manually deleted files that I perhaps shouldn't have.
It tried to load libpq.5.dylib from the symlink /opt/homebrew/opt/postgresql/lib/libpq.5.dylib but could not find the file, so you need to update it:
# TODO: get this from the error, after "Library not loaded:"
SYMLINK_PATH="/opt/homebrew/opt/postgresql/lib/libpq.5.dylib"
# TODO: find this in your machine. The version maybe different than mine
DESTINATION_PATH="/opt/homebrew/opt/postgresql/lib/postgresql#14/libpq.5.dylib"
sudo mv $SYMLINK_PATH $SYMLINK_PATH.old
sudo ln -s $DESTINATION_PATH $SYMLINK_PATH

After install djanog and try to runserver manage.py I get ImportError

I'm new and trying to follow this tutorial:
https://www.youtube.com/watch?v=_uQrJ0TkZlc
from 05:00:00 I follow him just like he doing, then at 05:05:04 when he run the server it's work fine for him, but for me is not.
This is exactly my steps....
After Install django like this:
pip install django
I write this:
django-admin startproject pyshop .
so far all good, no error, then I try to run the server like this:
python manage.py runserver
But then I get a big error:
Exception ignored in thread started by: <function check_errors.<locals>.wrapper at 0x000001D36DA79AF0>
Traceback (most recent call last):
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\utils\autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\core\management\__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\apps\registry.py", line 112, in populate
app_config.import_models()
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\apps\config.py", line 198, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\contrib\auth\models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\db\models\base.py", line 101, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\db\models\base.py", line 304, in add_to_class
value.contribute_to_class(cls, name)
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\db\models\options.py", line 203, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\db\__init__.py", line 33, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\db\utils.py", line 202, in __getitem__
backend = load_backend(db['ENGINE'])
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\db\utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name)
File "C:\Users\anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "D:\User\OneDrive\Programing Code\Python\PyShop\venv\lib\site-packages\django\db\backends\sqlite3\base.py", line 10, in <module>
from sqlite3 import dbapi2 as Database
File "C:\Users\anaconda3\lib\sqlite3\__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "C:\Users\anaconda3\lib\sqlite3\dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: DLL load failed while importing _sqlite3: The specified module could not be found.
Help :(
Try by downloading the sqlite3 dll (find version that supports your system)
And put it into the folder: C:\Users\YOURUSER\Anaconda3\DLLs
Install python3 and then run python3 manage.py runserver
Suppose you're not using Anaconda, you can download sqlite3 dll and add it to your system32 C:\Windows\System32 if you're using windows that is

I keep getting NotImplementedError error when starting django server [duplicate]

This question already has answers here:
Jupyter Notebook with Python 3.8 - NotImplementedError
(4 answers)
Closed 3 years ago.
Below is a full trace of the error. Please let me know what could fix this issue:
(env) C:\Users\LENOVO\Desktop\SD\backend>python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\LENOVO\Desktop\SD\backend\env\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\LENOVO\Desktop\SD\backend\env\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\LENOVO\Desktop\SD\backend\env\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception
raise _exception[1]
File "C:\Users\LENOVO\Desktop\SD\backend\env\lib\site-packages\django\core\management\__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\LENOVO\Desktop\SD\backend\env\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\LENOVO\Desktop\SD\backend\env\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\LENOVO\Desktop\SD\backend\env\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\LENOVO\Desktop\SD\backend\env\lib\site-packages\django\apps\config.py", line 116, in create
mod = import_module(mod_path)
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python38-32\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\LENOVO\Desktop\SD\backend\env\lib\site-packages\channels\apps.py", line 6, in <module>
import daphne.server
File "C:\Users\LENOVO\Desktop\SD\backend\env\lib\site-packages\daphne\server.py", line 18, in <module>
asyncioreactor.install()
File "C:\Users\LENOVO\Desktop\SD\backend\env\lib\site-packages\twisted\internet\asyncioreactor.py", line 320, in install
reactor = AsyncioSelectorReactor(eventloop)
File "C:\Users\LENOVO\Desktop\SD\backend\env\lib\site-packages\twisted\internet\asyncioreactor.py", line 69, in __init__
super().__init__()
File "C:\Users\LENOVO\Desktop\SD\backend\env\lib\site-packages\twisted\internet\base.py", line 571, in __init__
self.installWaker()
File "C:\Users\LENOVO\Desktop\SD\backend\env\lib\site-packages\twisted\internet\posixbase.py", line 286, in installWaker
self.addReader(self.waker)
File "C:\Users\LENOVO\Desktop\SD\backend\env\lib\site-packages\twisted\internet\asyncioreactor.py", line 151, in addReader
self._asyncioEventloop.add_reader(fd, callWithLogger, reader,
File "C:\Users\LENOVO\AppData\Local\Programs\Python\Python38-32\lib\asyncio\events.py", line 501, in add_reader
raise NotImplementedError
NotImplementedError
Twisted is not supported on 3.8 on Windows, so one solution would be to switch back to Python 3.7.
I got it working on Python 3.8 by replacing the following lines in packages/twisted/internet/asyncioreactor.py
from twisted.internet.interfaces import IReactorFDSet
try:
from asyncio import get_event_loop
except ImportError:
raise ImportError("Requires asyncio.")
# As per ImportError above, this module is never imported on python 2, but
with
from twisted.internet.interfaces import IReactorFDSet
import sys
try:
from asyncio import get_event_loop, set_event_loop_policy, WindowsSelectorEventLoopPolicy
except ImportError:
raise ImportError("Requires asyncio.")
if sys.platform == 'win32':
set_event_loop_policy(WindowsSelectorEventLoopPolicy())
# As per ImportError above, this module is never imported on python 2, but
From the similar problem faced by Tornado here.

While giving the command - python manage.py runserver, it shows the given error

Error while executing python manage.py runserver
enter code here Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File
"c:\users\hp\appdata\local\programs\python\python37\Lib\threading.py",
line 917, in _bootstrap_inner
self.run()
File "c:\users\hp\appdata\local\programs\python\python37\Lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\HP\Desktop\iam_orm_layer\env\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\HP\Desktop\iam_orm_layer\env\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\HP\Desktop\iam_orm_layer\env\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception
raise _exception[1]
File "C:\Users\HP\Desktop\iam_orm_layer\env\lib\site-packages\django\core\management\__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\HP\Desktop\iam_orm_layer\env\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\HP\Desktop\iam_orm_layer\env\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\HP\Desktop\iam_orm_layer\env\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\HP\Desktop\iam_orm_layer\env\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\HP\Desktop\iam_orm_layer\env\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\HP\Desktop\iam_orm_layer\env\lib\site-packages\rest_framework_filters\__init__.py", line 3, in <module>
from .filterset import FilterSet
File "C:\Users\HP\Desktop\iam_orm_layer\env\lib\site-packages\rest_framework_filters\filterset.py", line 10, in <module>
from django_filters import filterset, rest_framework
File "C:\Users\HP\Desktop\iam_orm_layer\env\lib\site-packages\django_filters\__init__.py", line 7, in <module>
from .filterset import FilterSet
File "C:\Users\HP\Desktop\iam_orm_layer\env\lib\site-packages\django_filters\filterset.py", line 15, in <module>
from .filters import (
File "C:\Users\HP\Desktop\iam_orm_layer\env\lib\site-packages\django_filters\filters.py", line 10, in <module>
from django.db.models.sql.constants import QUERY_TERMS
ImportError: cannot import name 'QUERY_TERMS' from 'django.db.models.sql.constants' (C:\Users\HP\Desktop\iam_orm_layer\env\lib\site-packages\django\db\models\sql\constants.py)
Already answered here:
Could not import QUERY_TERMS
The constant you are trying to import does not exist in the django filters version you are using

Django Haystack ElasticSearch Python3

my plan is to get Django with an ElasticSearch backend running using Python3 on a Debian 7.5-64bit machine.
I'll explain every single step, cause i'm nor a professional admin, neither a ready developer.
Not to forget, i'm dealing with this problem the third evening and i feels like i have tried every single tip in the internet.
First, I unpacked, configured, made, made test, made install Python-3.4.1 in my /usr/local/. This created links/bins in usr/local/bin. So i created symlinks from /usr/bin to /usr/local/bin and "installed" different python3 (3.2 from within debian, and 3.4) with update-alternatives. I created alternatives for python3 and python3-config.
The same with Java 8u11 Server-JRE.
I went on installing Django 1.6.5, Haystack 2.1, pyelasticsearch 0.6.1 with at least EVERY pip installed in /usr/bin and /usr/local/bin (pip has also installed requests 2.3.0, simplejson 3.6.0, six 1.7.3).
Meanwhile i also installed pyes 0.99.2 and urllib3 1.9. Both with pip.
Django is configured and running, also apache with mod-wsgi modul. I created a django project and an app (no models yet).
Elasticsearch is also running, but without any indizes yet.
To my project/settings.py i edited and added:
INSTALLED_APPS = {...
'haystack'}
...
DATABASES = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'NAME': 'haystack',
}
...
}
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine',
'URL': 'http://127.0.0.1:9200/',
'INDEX_NAME': 'haystack',
},
}
When i run ./manage.py from within projectfolder I get following error:
./manage.py syncdb
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python2.7/dist-packages/django/core/management/base.py", line 280, in execute
translation.activate('en-us')
File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 130, in activate
return _trans.activate(language)
File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 188, in activate
_active.value = translation(language)
File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 159, in _fetch
app = import_module(appname)
File "/usr/local/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module
__import__(name)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/__init__.py", line 6, in <module>
from django.contrib.admin.sites import AdminSite, site
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py", line 4, in <module>
from django.contrib.admin.forms import AdminAuthenticationForm
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/forms.py", line 6, in <module>
from django.contrib.auth.forms import AuthenticationForm
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/forms.py", line 17, in <module>
from django.contrib.auth.models import User
File "/usr/local/lib/python2.7/dist-packages/django/contrib/auth/models.py", line 48, in <module>
class Permission(models.Model):
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 96, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py", line 264, in add_to_class
value.contribute_to_class(cls, name)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/options.py", line 124, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/usr/local/lib/python2.7/dist-packages/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 198, in __getitem__
backend = load_backend(db['ENGINE'])
File "/usr/local/lib/python2.7/dist-packages/django/db/utils.py", line 131, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'
Error was: No module named ElasticsearchSearchEngine.base
And like the shebang in manage.py says, this so uses python2.7.
Then forcing my python 3.4 interpeter:
python3 ./manage.py syncdb
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 2218, in _find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.4/site-packages/django/db/utils.py", line 113, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/local/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2221, in _find_and_load_unlocked
ImportError: No module named 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine'; 'haystack.backends.elasticsearch_backend' is not a package
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 399, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.4/site-packages/django/core/management/__init__.py", line 392, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.4/site-packages/django/core/management/base.py", line 242, in run_from_argv
self.execute(*args, **options.__dict__)
File "/usr/local/lib/python3.4/site-packages/django/core/management/base.py", line 280, in execute
translation.activate('en-us')
File "/usr/local/lib/python3.4/site-packages/django/utils/translation/__init__.py", line 130, in activate
return _trans.activate(language)
File "/usr/local/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 188, in activate
_active.value = translation(language)
File "/usr/local/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 177, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "/usr/local/lib/python3.4/site-packages/django/utils/translation/trans_real.py", line 159, in _fetch
app = import_module(appname)
File "/usr/local/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2226, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 1200, in _load_unlocked
File "<frozen importlib._bootstrap>", line 1129, in _exec
File "<frozen importlib._bootstrap>", line 1471, in exec_module
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "/usr/local/lib/python3.4/site-packages/django/contrib/admin/__init__.py", line 6, in <module>
from django.contrib.admin.sites import AdminSite, site
File "/usr/local/lib/python3.4/site-packages/django/contrib/admin/sites.py", line 4, in <module>
from django.contrib.admin.forms import AdminAuthenticationForm
File "/usr/local/lib/python3.4/site-packages/django/contrib/admin/forms.py", line 6, in <module>
from django.contrib.auth.forms import AuthenticationForm
File "/usr/local/lib/python3.4/site-packages/django/contrib/auth/forms.py", line 17, in <module>
from django.contrib.auth.models import User
File "/usr/local/lib/python3.4/site-packages/django/contrib/auth/models.py", line 48, in <module>
class Permission(models.Model):
File "/usr/local/lib/python3.4/site-packages/django/db/models/base.py", line 96, in __new__
new_class.add_to_class('_meta', Options(meta, **kwargs))
File "/usr/local/lib/python3.4/site-packages/django/db/models/base.py", line 264, in add_to_class
value.contribute_to_class(cls, name)
File "/usr/local/lib/python3.4/site-packages/django/db/models/options.py", line 124, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/usr/local/lib/python3.4/site-packages/django/db/__init__.py", line 34, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/usr/local/lib/python3.4/site-packages/django/db/utils.py", line 198, in __getitem__
backend = load_backend(db['ENGINE'])
File "/usr/local/lib/python3.4/site-packages/django/db/utils.py", line 131, in load_backend
raise ImproperlyConfigured(error_msg)
django.core.exceptions.ImproperlyConfigured: 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine' isn't an available database backend.
Try using 'django.db.backends.XXX', where XXX is one of:
'mysql', 'oracle', 'postgresql_psycopg2', 'sqlite3'
Error was: No module named 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine'; 'haystack.backends.elasticsearch_backend' is not a package
A ls shows, that the file is there, and with an editor i see, that the class exists
/usr/local/lib/python3.4/site-packages/haystack/backends/elasticsearch_backend.py
Did I forget ANYTHING? Should there be anything in "PYTHONPATH" which is under python-lib directory? Which information could also be important?
At least: Is this setup even possible? Did i understand the structure of django-haystack and database-backend correct?
Please help me. I'm tired of and done with the docu and samples from django, haystack, elasticsearch and the most targeting google hits.
syncdb command will try to sync your models with the database. Django is not able to interpret ElasticsearchSearchEngine as a database. You should use correct ENGINE value corresponding to the database you are using.
e.g. For MySQL
ENGINE='django.db.backends.mysql'
Do you intend to use database at all? If not then do not run syncdb.
Your database setting is wrong. You should use any of the database engine here like :
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'mydatabase',
}
}
if you choose to use sqlite database in your project.