Django: Why is package not found in virutal environment? - python

I am currently setting up a simple search in django using the elastic search and haystack packages.
However, when I run the server , it occures the following error:
(development_env) C:\Users\user\Desktop\Development\development>python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception
raise _exception[1]
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\core\management\__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\user\AppData\Local\Programs\Python\Python38\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 973, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'elasticsearch-dsl'
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\utils\autoreload.py", line 598, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\utils\autoreload.py", line 583, in start_django
reloader.run(django_main_thread)
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\utils\autoreload.py", line 301, in run
self.run_loop()
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\utils\autoreload.py", line 307, in run_loop
next(ticker)
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\utils\autoreload.py", line 347, in tick
for filepath, mtime in self.snapshot_files():
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\utils\autoreload.py", line 363, in snapshot_files
for file in self.watched_files():
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\utils\autoreload.py", line 262, in watched_files
yield from iter_all_python_module_files()
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\utils\autoreload.py", line 103, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "C:\Users\user\Desktop\Development\development\development_env\lib\site-packages\django\utils\autoreload.py", line 139, in iter_modules_and_files
if not path.exists():
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\pathlib.py", line 1385, in exists
self.stat()
File "C:\Users\user\AppData\Local\Programs\Python\Python38\lib\pathlib.py", line 1191, in stat
return self._accessor.stat(self)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '<frozen importlib._bootstrap>'
I particularly wondering about the error: ModuleNotFoundError: No module named 'elasticsearch-dsl'.
If I check my installed packages, I see that 'elasticsearch-dsl' is installed:
(development_env) C:\Users\user\Desktop\Development\development>pip list
Package Version
------------------------ -------
appdirs 1.4.3
asgiref 3.2.3
distlib 0.3.0
Django 2.2.10
django-crispy-forms 1.8.1
django-elasticsearch-dsl 7.1.1
django-haystack 2.8.1
django-six 1.0.4
elasticsearch 7.5.1
elasticsearch-dsl 7.1.0
filelock 3.0.12
Pillow 7.0.0
pip 19.2.3
python-dateutil 2.8.1
pytz 2019.3
setuptools 41.2.0
six 1.14.0
sqlparse 0.3.0
urllib3 1.25.8
virtualenv 20.0.5
virtualenvwrapper-win 1.2.6
I also checked 'django-elasticsearch-dsl' instead of 'elasticsearch-dsl' but the error code is the same. I seems that the elastic search package is somehow not correctly installed in my virutal environment.
I'm thankful for every hint.
Greetings Daniel

You have to add the package inside of your app/settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
....
'elasticsearch-dsl'
]
The error should disappear.
Greetings Alex

Related

Postgresql not working with django on Macos: El Capitan

I installed Postgresql from the official site (version 4.0), I created a database with "pgAdmin 4", and tried to connect my django project to it.
But an error prevented me from the running the django server, the error says:
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 25, in <module>
import psycopg2 as Database
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/psycopg2/__init__.py", line 51, in <module>
from psycopg2._psycopg import ( # noqa
ImportError: dlopen(/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so, 2): Symbol not found: ____chkstk_darwin
Referenced from: /Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/psycopg2/.dylibs/libcrypto.1.1.dylib
Expected in: /usr/lib/libSystem.B.dylib
in /Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/psycopg2/.dylibs/libcrypto.1.1.dylib
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 973, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 910, in run
self._target(*self._args, **self._kwargs)
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/core/management/__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/Library/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/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/contrib/auth/base_user.py", line 48, in <module>
class AbstractBaseUser(models.Model):
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/db/models/base.py", line 122, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/db/models/base.py", line 326, in add_to_class
value.contribute_to_class(cls, name)
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/db/models/options.py", line 206, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/db/__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/db/utils.py", line 214, in __getitem__
backend = load_backend(db['ENGINE'])
File "/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/db/utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
File "/Library/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/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/django/db/backends/postgresql/base.py", line 29, in <module>
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading psycopg2 module: dlopen(/Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/psycopg2/_psycopg.cpython-39-darwin.so, 2): Symbol not found: ____chkstk_darwin
Referenced from: /Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/psycopg2/.dylibs/libcrypto.1.1.dylib
Expected in: /usr/lib/libSystem.B.dylib
in /Users/yyy/.local/share/virtualenvs/mysite-G0YpajmP/lib/python3.9/site-packages/psycopg2/.dylibs/libcrypto.1.1.dylib
The django project is created inside a "pipenv" virtual environment with the following pip packages installed:
asgiref 3.4.1
certifi 2021.10.8
charset-normalizer 2.0.7
cPython 0.0.6
Django 3.1.13
idna 3.3
pip 21.2.4
postgres 4.0
psycopg2-binary 2.9.1
psycopg2-pool 1.1
pymongo 3.12.1
pytz 2021.3
requests 2.26.0
setuptools 58.2.0
sqlparse 0.4.2
urllib3 1.26.7
wheel 0.37.0
I tried other solutions but all of them didn't work.
Why doesn't postgresql run probably with django on my machine?
I solved the problem by downloading Anaconda
and xcode for OS X EL CAPITAN 10.11.6 from here
Anaconda has psycopg2 and downloads it without any problems.
Now I have a conda virtual environment with Django + postgresql installed, working perfectly with EL CAPITAN 10.11.6.
Thumbs up for #RichardHuxton comment: the problem was the django project virtual environment.

Is there a way to solve OS Error in Django Project

I started learning Django recently.
I first ran the virtual enviroment, then installed Django and then python manage.py runserverbut im recieving this error:
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\123\AppData\Local\Programs\Python\Python39\lib\threading.py", line 950, in _bootstrap_inner
self.run()
File "C:\Users\123\AppData\Local\Programs\Python\Python39\lib\threading.py", line 888, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper fn(*args, **kwargs)
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\core\management\__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper fn(*args, **kwargs)
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\123\AppData\Local\Programs\Python\Python39\lib\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 984, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'allauth'
Traceback (most recent call last):
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\manage.py", line 14, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\core\management\__init__.py", line 401, in execute_from_command_line
utility.execute()
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\core\management\__init__.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\core\management\base.py", line 330, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\core\management\commands\runserver.py", line 61, in execute
super().execute(*args, **options)
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\core\management\base.py", line 371, in execute
output = self.handle(*args, **options)
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\core\management\commands\runserver.py", line 96, in handle
self.run(**options)
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\core\management\commands\runserver.py", line 103, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\utils\autoreload.py", line 618, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\utils\autoreload.py", line 603, in start_django
reloader.run(django_main_thread)
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\utils\autoreload.py", line 318, in run
self.run_loop()
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\utils\autoreload.py", line 324, in run_loop
next(ticker)
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\utils\autoreload.py", line 364, in tick
for filepath, mtime in self.snapshot_files():
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\utils\autoreload.py", line 380, in snapshot_files
for file in self.watched_files():
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\utils\autoreload.py", line 278, in watched_files
yield from iter_all_python_module_files()
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\utils\autoreload.py", line 105, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "C:\Users\123\Downloads\django-react-boilerplate-master\django-react-boilerplate-master\env\lib\site-packages\django\utils\autoreload.py", line 141, in iter_modules_and_files
resolved_path = path.resolve(strict=True).absolute()
File "C:\Users\123\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 1204, in resolve
s = self._flavour.resolve(self, strict=strict)
File "C:\Users\123\AppData\Local\Programs\Python\Python39\lib\pathlib.py", line 200, in resolve
return self._ext_to_normal(_getfinalpathname(s))
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '<frozen importlib._bootstrap>'
I downloaded this https://github.com/justdjango/django-react-boilerplate project and was trying to run this in the terminal.
If someone can help please. Thankyou.
The problem is in your setup. After activating your environment, run this command;
pip install -r requirements.txt
As you downloaded the code from the mentioned link, that also has a file, requirements.txt which shows all the modules required to make the project run and the above command will install all of them at once.
After that run;
python manage.py makemigrations
python manage.py migrate
Then you will be ready;
python manage.py ruunserver

Watching for file changes with StatReloader Exception in thread django-main-thread:

**Don't know what the problem is. I am not able to run any of my Django servers.
Every time gets the same error.
And don't have any idea about this.
Tried reinstalling windows, python and all. But still gets same error.
**
Don't know what the problem is. I am not able to run any of my Django servers.
Every time gets the same error.
And don't have any idea about this.
Tried reinstalling windows, python and all. But still gets same error.
C:\Users\JamesBond\Desktop\ONLINE WEBSITES\vishwatradelink_>manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception
raise _exception[1]
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\apps\config.py", line 90, in create
module = import_module(entry)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\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 965, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'crispy_forms'
Traceback (most recent call last):
File "C:\Users\JamesBond\Desktop\ONLINE WEBSITES\vishwatradelink_\manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 598, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 583, in start_django
reloader.run(django_main_thread)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 301, in run
self.run_loop()
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 307, in run_loop
next(ticker)
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 347, in tick
for filepath, mtime in self.snapshot_files():
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 363, in snapshot_files
for file in self.watched_files():
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 262, in watched_files
yield from iter_all_python_module_files()
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 103, in iter_all_python_module_files
return iter_modules_and_files(modules, frozenset(_error_files))
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\site-packages\django\utils\autoreload.py", line 139, in iter_modules_and_files
if not path.exists():
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\pathlib.py", line 1346, in exists
self.stat()
File "C:\Users\JamesBond\AppData\Local\Programs\Python\Python37-32\lib\pathlib.py", line 1168, in stat
return self._accessor.stat(self)
OSError: [WinError 123] The filename, directory name, or volume label syntax is incorrect: '<frozen importlib._bootstrap>'**
Run the following commands:
(write python according to your OS this commands below are for windows)
1) python manage.py makemigrations
and then
2) python manage.py migrate
Mostly, this will make your command
python manage.py runserver work!
From the error message that you are getting check there is a line:
ModuleNotFoundError: No module named 'crispy_forms'
This means in your settings.py file you have 'crispy_forms' among the installed apps but this time its not included in your python environment. To resolve this you have to install crispy_forms using
pip install django-crispy-forms
For more on django-crispy-forms see the documentation https://django-crispy-forms.readthedocs.io/en/latest/install.html
**No module named 'crispy_forms'
this is the problem
OR
command is python manage.py runserver, not manage.py runserver
In my case I have added the name of my app before creating that app in the settings.py file of the main project. Kindly add the name of your app in settings.py file after creating the app. That's why you are not able to run the server
If you have this problem, go to the settings.py file, and check for comas, and if rest_framework is correctly spelled.
Make sure to be in the right virtual environment you previously worked on because everything you previously installed like rest_framework, django will be stored in that environment, and try running the command.
python manage.py runserver

How to start server with "python manage.py runserver" whithout errors?

I installed Django with: conda create --name myproject django
Every check I made (environement, django, versions, etc) seems to be alright and I don't know what the problem is.
What I have:
(myproject) D:\###Work###\###INFORMATICA###\###PYTHON###\MySite>python -V
Python 3.7.3
(myproject) D:\###Work###\###INFORMATICA###\###PYTHON###\MySite>conda -V
conda 4.6.14
(myproject) D:\###Work###\###INFORMATICA###\###PYTHON###\MySite>conda
list
packages in environment at C:\ProgramData\Anaconda3\envs\myproject:
Name Version Build Channel
astroid 2.2.5 py37_0
ca-certificates 2019.1.23 0
certifi 2019.3.9 py37_0
colorama 0.4.1 py37_0
django 2.2 py37_0
isort 4.3.17 py37_0
lazy-object-proxy 1.3.1 py37hfa6e2cd_2
mccabe 0.6.1 py37_1
openssl 1.1.1b he774522_1
pip 19.1 py37_0
pylint 2.3.1 py37_0
python 3.7.3 h8c8aaf0_1
pytz 2019.1 py_0
setuptools 41.0.1 py37_0
six 1.12.0 py37_0
sqlite 3.28.0 he774522_0
vc 14.1 h0510ff6_4
vs2015_runtime 14.15.26706 h3a45250_4
wheel 0.33.1 py37_0
wincertstore 0.2 py37_0
wrapt 1.11.1 py37he774522_0
(myproject) D:\###Work###\###INFORMATICA###\###PYTHON###\MySite> conda
info --envs
conda environments:
base C:\ProgramData\Anaconda3
myproject * C:\ProgramData\Anaconda3\envs\myproject
'# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
And this is the output for : python manage.py runserver
(tried to add an IP and port but still no solution)
(myproject) D:\###Work###\###INFORMATICA###\###PYTHON###\MySite>python manage.py runserver
Watching for file changes with StatReloader Exception in thread Thread-1: Traceback (most recent call last): File "C:\ProgramData\Anaconda3\envs\myproject\lib\threading.py", line 917, in _bootstrap_inner
self.run() File "C:\ProgramData\Anaconda3\envs\myproject\lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception() File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\utils\autoreload.py", line 77, in raise_last_exception
raise _exception[0](_exception[1]).with_traceback(_exception[2]) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models() File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name) File "C:\ProgramData\Anaconda3\envs\myproject\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:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\contrib\auth\models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model): File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\db\models\base.py", line 117, in __new__
new_class.add_to_class('_meta', Options(meta, app_label)) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\db\models\base.py", line 321, in add_to_class
value.contribute_to_class(cls, name) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\db\models\options.py", line 204, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\db\__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\db\utils.py", line 201, in __getitem__
backend = load_backend(db['ENGINE']) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\db\utils.py", line 110, in load_backend
return import_module('%s.base' % backend_name) File "C:\ProgramData\Anaconda3\envs\myproject\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\db\backends\sqlite3\base.py", line 28, in <module>
from .introspection import DatabaseIntrospection # isort:skip File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\db\backends\sqlite3\introspection.py", line 4, in <module>
import sqlparse ModuleNotFoundError: No module named 'sqlparse' Traceback (most recent call last): File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\apps\registry.py", line 155, in get_app_config
return self.app_configs[app_label] KeyError: 'admin' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "manage.py", line 21, in <module>
main() File "manage.py", line 17, in main
execute_from_command_line(sys.argv) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute() File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\utils\autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\utils\autoreload.py", line 564, in start_django
reloader.run(django_main_thread) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\utils\autoreload.py", line 272, in run
get_resolver().urlconf_module File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\utils\functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\urls\resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name) File "C:\ProgramData\Anaconda3\envs\myproject\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 "D:\###Work###\###INFORMATICA###\###PYTHON###\MySite\MySite\urls.py", line 20, in <module>
path('admin/', admin.site.urls), File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\utils\functional.py", line 256, in inner
self._setup() File "C:\ProgramData\Anaconda3\envs\myproject\lib\site-packages\django\contrib\admin\sites.py", line 529, in _setup
AdminSiteClass = import_string(apps.get_app_config('admin').default_site) File "C:\ProgramData\Anaconda3\envs\myproject\lib\site->packages\django\apps\registry.py", line 162, in get_app_config
raise LookupError(message) LookupError: No installed app with label 'admin'.
(myproject) D:\###Work###\###INFORMATICA###\###PYTHON###\MySite
What could be the solution to the problem?
I found out an answer.
It seems that conda package manager is not working properly on my windows 10 installation.The solution is to install with pip package manager.
With the virtual environement active the command is:
pip install django --force
Hope that no one will spend so much time, to figure out a verry simple solution.
Ceers!

Running python manage.py runserver returns error LookupError: No installed app with label 'admin'

I'm trying to run python manage.py runserver but i'm getting
LookupError: No installed app with label 'admin'
this is what i get by python manage.py check
Traceback (most recent call last): File "manage.py", line 21, in
main() File "manage.py", line 17, in main
execute_from_command_line(sys.argv) File "C:\Users\hitma\Envs\ftest\lib\site-packages\django\core\management__init__.py",
line 381, in execute_from_command_line
utility.execute() File "C:\Users\hitma\Envs\ftest\lib\site-packages\django\core\management__init__.py",
line 357, in execute
django.setup() File "C:\Users\hitma\Envs\ftest\lib\site-packages\django__init__.py", line
24, in setup
apps.populate(settings.INSTALLED_APPS) File "C:\Users\hitma\Envs\ftest\lib\site-packages\django\apps\registry.py",
line 114, in populate
app_config.import_models() File "C:\Users\hitma\Envs\ftest\lib\site-packages\django\apps\config.py",
line 211, in import_models
self.models_module = import_module(models_module_name) File "C:\Users\hitma\Envs\ftest\lib\importlib__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level) File "", line 996, in _gcd_import File
"", line 979, in _find_and_load File
"", line 968, in _find_and_load_unlocked
File "", line 673, in _load_unlocked
File "", line 667, in
exec_module File "", line 222, in
_call_with_frames_removed File "C:\Users\hitma\Envs\ftest\lib\site-packages\django\contrib\auth\models.py",
line 2, in
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager File
"C:\Users\hitma\Envs\ftest\lib\site-packages\django\contrib\auth\base_user.py",
line 47, in
class AbstractBaseUser(models.Model): File "C:\Users\hitma\Envs\ftest\lib\site-packages\django\db\models\base.py",
line 117, in new
new_class.add_to_class('_meta', Options(meta, app_label)) File "C:\Users\hitma\Envs\ftest\lib\site-packages\django\db\models\base.py",
line 321, in add_to_class
value.contribute_to_class(cls, name) File "C:\Users\hitma\Envs\ftest\lib\site-packages\django\db\models\options.py",
line 204, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length()) File
"C:\Users\hitma\Envs\ftest\lib\site-packages\django\db__init__.py",
line 28, in getattr
return getattr(connections[DEFAULT_DB_ALIAS], item) File "C:\Users\hitma\Envs\ftest\lib\site-packages\django\db\utils.py", line
201, in getitem
backend = load_backend(db['ENGINE']) File "C:\Users\hitma\Envs\ftest\lib\site-packages\django\db\utils.py", line
110, in load_backend
return import_module('%s.base' % backend_name) File "C:\Users\hitma\Envs\ftest\lib\importlib__init__.py", line 126, in
import_module
return _bootstrap._gcd_import(name[level:], package, level) File "C:\Users\hitma\Envs\ftest\lib\site-packages\django\db\backends\sqlite3\base.py",
line 28, in
from .introspection import DatabaseIntrospection # isort:skip File
"C:\Users\hitma\Envs\ftest\lib\site-packages\django\db\backends\sqlite3\introspection.py",
line 4, in
import sqlparse File "C:\Users\hitma\Envs\ftest\lib\site-packages\sqlparse__init__.py",
line 16, in
from sqlparse import filters File "C:\Users\hitma\Envs\ftest\lib\site-packages\sqlparse\filters__init__.py",
line 17, in
from sqlparse.filters.tokens import KeywordCaseFilter File "C:\Users\hitma\Envs\ftest\lib\site-packages\sqlparse\filters\tokens.py",
line 27, in
class KeywordCaseFilter(_CaseFilter): TypeError: '_TokenType' object is not callable
i followed the main doucment for installing django,Thanks
django version: 2.2
python: 3.6.0a4
It is an issue related to sqlparse. It happens when you are using newest version of packages.
Try :
pip install sqlparse
Note - your terminal must activate virtual environment.
I think you are facing this issue in SQLParse, which led to this Python issue.
I believe the issue will be resolved if you update Python from 3.6 alpha to the latest 3.6.X or 3.7.X release.

Categories

Resources