ModuleNotFoundError: No module named 'django.config' using celery and rabbitmq - python

I'm getting this error after running the following command:
C:\Users\callu\project_name>celery -A project_name worker -l info
I'm wondering if it has something to do with the fact that I've not created my django project in a virtual environment but I can't find anything on the issue. If it was due to it being outside a virtual environment I'm not sure how I'd get around it without restarting the project in one (is it easy to move to a venv in PyCharm?)
I run my django server and my above celery command here:
C:\Users\callu\project_name>
I run start my RabbitMQ server in another location (not venv) but don't think that's the issue
Full Traceback:
Traceback (most recent call last):
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\cached_property.py", line 70, in __get__
return obj_dict[name]
KeyError: 'data'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\callu\AppData\Local\Programs\Python\Python37-32\Scripts\celery.exe\__main__.py", line 7, in <module>
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\__main__.py", line 15, in main
sys.exit(_main())
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\bin\celery.py", line 213, in main
return celery(auto_envvar_prefix="CELERY")
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 717, in main
rv = self.invoke(ctx)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 1135, in invoke
sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 641, in make_context
self.parse_args(ctx, args)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 940, in parse_args
value, args = param.handle_parse_result(ctx, opts, args)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 1477, in handle_parse_result
self.callback, ctx, self, value)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\click\core.py", line 96, in invoke_param_callback
return callback(ctx, param, value)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\bin\worker.py", line 156, in <lambda>
value: value or ctx.obj.app.conf.worker_state_db,
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\utils\collections.py", line 111, in __getattr__
return self[k]
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\utils\collections.py", line 391, in __getitem__
return getitem(k)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\utils\collections.py", line 249, in __getitem__
return mapping[_key]
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\collections\__init__.py", line 1021, in __getitem__
if key in self.data:
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\kombu\utils\objects.py", line 29, in __get__
return super().__get__(instance, owner)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\cached_property.py", line 74, in __get__
return obj_dict.setdefault(name, self.func(obj))
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\app\base.py", line 138, in data
return self.callback()
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\app\base.py", line 946, in _finalize_pending_conf
conf = self._conf = self._load_config()
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\app\base.py", line 956, in _load_config
self.loader.config_from_object(self._config_source)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\loaders\base.py", line 123, in config_from_object
obj = self._smart_import(obj, imp=self.import_from_cwd)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\loaders\base.py", line 136, in _smart_import
return symbol_by_name(path, imp=imp)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\kombu\utils\imports.py", line 56, in symbol_by_name
module = imp(module_name, package=package, **kwargs)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\loaders\base.py", line 95, in import_from_cwd
package=package,
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\utils\imports.py", line 100, in import_from_cwd
return imp(module, package=package)
File "c:\users\callu\appdata\local\programs\python\python37-32\lib\site-packages\celery\loaders\base.py", line 89, in import_module
return importlib.import_module(module, package=package)
File "c:\users\callu\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 'django.config'

It sounds like you have somewhere (in your app/celery.py if using the standard layout) a line that looks like:
app.config_from_object('django.config:settings', namespace='CELERY')
where app is your Celery app object.
But what you need is:
app.config_from_object('django.conf:settings', namespace='CELERY')
Note: you the django config module is django.conf not django.config.

Related

Error during run the program runtime error

These are apps installed in my django project. the apps with vip_number.* are inside the innerproject folder. but i got the issue here that my apps are not installed in seetings.py where as they are already there
INSTALLED_APPS = [
'whitenoise.runserver_nostatic',
'jet',
'jet.dashboard',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'vip_number.users',
'vip_admin',
'vip_number.base',
'vip_number.categories',
'vip_number.category_tag',
'vip_number.category_numbers',
'vip_number.number',
'vip_number.paytm',
'vip_number.subscribers',
'vip_number.homeimages',
'vip_number.testimonial',
'vip_number.faq',
'tagconstants',
'sekizai',
'vip_number.wawebplus',
'contact',
]
error
(djangoenv) PS E:\download\VIP number\vip_number> python manage.py runserver
Exception in thread django-main-thread:
Traceback (most recent call last):
File "E:\download\VIP number\djangoenv\lib\site-packages\django\apps\config.py", line 244, in create
app_module = import_module(app_name)
File "C:\Users\its simi\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1004, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'base'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\its simi\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1009, in _bootstrap_inner
self.run()
File "C:\Users\its simi\AppData\Local\Programs\Python\Python310\lib\threading.py", line 946, in run
self._target(*self._args, **self._kwargs)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\core\management\commands\runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "E:\download\VIP number\djangoenv\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "E:\download\VIP number\djangoenv\lib\site-packages\django\core\management\__init__.py", line 375, in execute
autoreload.check_errors(django.setup)()
File "E:\download\VIP number\djangoenv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\apps\config.py", line 246, in create
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: Cannot import 'base'. Check that 'vip_number.base.apps.BaseConfig.name' is correct.
Traceback (most recent call last):
File "E:\download\VIP number\djangoenv\lib\site-packages\django\template\utils.py", line 66, in __getitem__
return self._engines[alias]
KeyError: 'django'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "E:\download\VIP number\vip_number\manage.py", line 20, in <module>
main()
File "E:\download\VIP number\vip_number\manage.py", line 16, in main
execute_from_command_line(sys.argv)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "E:\download\VIP number\djangoenv\lib\site-packages\django\core\management\__init__.py", line 413, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\core\management\base.py", line 354, in run_from_argv
self.execute(*args, **cmd_options)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\core\management\commands\runserver.py", line 61, in execute
super().execute(*args, **options)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\core\management\base.py", line 398, in execute
output = self.handle(*args, **options)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\core\management\commands\runserver.py", line 96, in handle
self.run(**options)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\core\management\commands\runserver.py", line 103, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\utils\autoreload.py", line 637, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\utils\autoreload.py", line 622, in start_django
reloader.run(django_main_thread)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\utils\autoreload.py", line 327, in run
autoreload_started.send(sender=self)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\dispatch\dispatcher.py", line 180, in send
return [
File "E:\download\VIP number\djangoenv\lib\site-packages\django\dispatch\dispatcher.py", line 181, in <listcomp>
(receiver, receiver(signal=self, sender=sender, **named))
File "E:\download\VIP number\djangoenv\lib\site-packages\django\template\autoreload.py", line 41, in watch_for_template_changes
for directory in get_template_directories():
File "E:\download\VIP number\djangoenv\lib\site-packages\django\template\autoreload.py", line 14, in get_template_directories
for backend in engines.all():
File "E:\download\VIP number\djangoenv\lib\site-packages\django\template\utils.py", line 90, in all
return [self[alias] for alias in self]
File "E:\download\VIP number\djangoenv\lib\site-packages\django\template\utils.py", line 90, in <listcomp>
return [self[alias] for alias in self]
File "E:\download\VIP number\djangoenv\lib\site-packages\django\template\utils.py", line 81, in __getitem__
engine = engine_cls(params)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\template\backends\django.py", line 27, in __init__
self.engine = Engine(self.dirs, self.app_dirs, **options)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\template\engine.py", line 51, in __init__
self.template_libraries = self.get_template_libraries(libraries)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\template\engine.py", line 93, in get_template_libraries
loaded[name] = import_library(path)
File "E:\download\VIP number\djangoenv\lib\site-packages\django\template\library.py", line 317, in import_library
module = import_module(name)
File "C:\Users\its simi\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "E:\download\VIP number\vip_number\templatetags\custom_tags.py", line 3, in <module>
from vip_number.users.models import User
File "E:\download\VIP number\vip_number\vip_number\users\models.py", line 3, in <module>
from django.contrib.auth.models import AbstractBaseUser
File "E:\download\VIP number\djangoenv\lib\site-packages\django\contrib\auth\models.py", line 5, in <module>
from django.contrib.contenttypes.models import ContentType
File "E:\download\VIP number\djangoenv\lib\site-packages\django\contrib\contenttypes\models.py", line 133, in <module>
class ContentType(models.Model):
File "E:\download\VIP number\djangoenv\lib\site-packages\django\db\models\base.py", line 113, in __new__
raise RuntimeError(
error i face
RuntimeError: Model class django.contrib.contenttypes.models.ContentType doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
(djangoenv) PS E:\download\VIP number\vip_number>

ImportError: [E048] Can't import language custom_en from spacy.lang: No module named 'spacy.lang.custom_en'

In spacy 3.0 I have registered my custom Language like this:
import spacy
from spacy.lang.en import English
class CustomEnglishDefaults(English.Defaults):
stop_words = set(["custom", "stop"])
#spacy.registry.languages("custom_en")
class CustomEnglish(English):
lang = "custom_en"
Defaults = CustomEnglishDefaults
I've tried the code line nlp = spacy.blank("custom_en") and it works fine.
But when I use lang="custom-en" in a config.cfg file and use the command :
python -m spacy train config.cfg --paths.train ./train.spacy --paths.dev ./dev.spacy
I get the following error:
Traceback (most recent call last):
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/spacy/util.py", line 244, in get_lang_class
module = importlib.import_module(f".lang.{lang}", "spacy")
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/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 'spacy.lang.custom_en'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/spacy/__main__.py", line 4, in <module>
setup_cli()
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/spacy/cli/_util.py", line 69, in setup_cli
command(prog_name=COMMAND)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/typer/main.py", line 497, in wrapper
return callback(**use_params) # type: ignore
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/spacy/cli/train.py", line 56, in train_cli
nlp = init_nlp(config, use_gpu=use_gpu)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/spacy/training/initialize.py", line 39, in init_nlp
nlp = load_model_from_config(raw_config, auto_fill=True)
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/spacy/util.py", line 425, in load_model_from_config
lang_cls = get_lang_class(nlp_config["lang"])
File "/home/marzi/anaconda3/envs/spacy-tutorial/lib/python3.8/site-packages/spacy/util.py", line 246, in get_lang_class
raise ImportError(Errors.E048.format(lang=lang, err=err)) from err
ImportError: [E048] Can't import language custom_en from spacy.lang: No module named 'spacy.lang.custom_en'
How can I solve this issue?
See the sidebar on the right in this section: https://spacy.io/usage/linguistic-features#language-subclass
python -m spacy train config.cfg --code code.py

AttributeError: function 'initGEOS_r' not found

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\Python38-32\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\core\management\__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\apps\registry.py", line 122, in populate
app_config.ready()
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\admin\apps.py", line 24, in ready
self.module.autodiscover()
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\admin\__init__.py", line 26, in autodiscover
autodiscover_modules('admin', register_to=site)
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\module_loading.py", line 47, in autodiscover_modules
import_module('%s.%s' % (app_config.name, module_to_search))
File "C:\Users\HP\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\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\gis\admin\__init__.py", line 5, in <module>
from django.contrib.gis.admin.options import GeoModelAdmin, OSMGeoAdmin
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\gis\admin\options.py", line 2, in <module>
from django.contrib.gis.admin.widgets import OpenLayersWidget
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\gis\admin\widgets.py", line 4, in <module>
from django.contrib.gis.geos import GEOSException, GEOSGeometry
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\gis\geos\__init__.py", line 5, in <module>
from .collections import ( # NOQA
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\gis\geos\collections.py", line 8, in <module>
from django.contrib.gis.geos.geometry import GEOSGeometry, LinearGeometryMixin
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\gis\geos\geometry.py", line 17, in <module>
from django.contrib.gis.geos.prototypes.io import (
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\gis\geos\prototypes\io.py", line 212, in <module>
class WKBWriter(IOBase):
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\gis\geos\prototypes\io.py", line 216, in WKBWriter
geos_version = geos_version_tuple()
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\gis\geos\libgeos.py", line 174, in geos_version_tuple
return get_version_tuple(geos_version().decode())
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\gis\geos\libgeos.py", line 169, in geos_version
return lgeos.GEOSversion()
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\functional.py", line 224, in inner
self._setup()
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\utils\functional.py", line 360, in _setup
self._wrapped = self._setupfunc()
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\site-packages\django\contrib\gis\geos\libgeos.py", line 66, in load_geos
_lgeos.initGEOS_r.restype = CONTEXT_PTR
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\ctypes\__init__.py", line 382, in __getattr__
func = self.__getitem__(name)
File "C:\Users\HP\AppData\Local\Programs\Python\Python38-32\lib\ctypes\__init__.py", line 387, in __getitem__
func = self._FuncPtr((name_or_ordinal, self))
AttributeError: function 'initGEOS_r' not found
I get AttributeError: function 'initGEOS_r' not found error while trying to run my server.
I am trying to write a basic Geo Django program
I have Postgres and GEOS also installed
I have also included GEOS and GDAL paths in my settings.py file.
I have tried all possible way to resolve this error but couldn't.
Can Someone Help me out!
I had the same problem this worked for me:
On settings.py write:
GDAL_LIBRARY_PATH = r'C:\OSGeo4W64\bin\gdal204'
GEOS_LIBRARY_PATH = r'C:\OSGeo4W64\bin\geos_c.dll'
PROJ_LIBRARY_PATH = r'C:\OSGeo4W64\share\proj'
On settings.py INSTALLED_APPS code:
'django.contrib.gis',
Add postgis to backend
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'xxx',
'USER': 'yyy',
'PASSWORD': 'xxx',
'HOST': '',
'PORT': '1234',
}
}
Remember that your models should inherit from
from django.contrib.gis.db import models
I hope this can help you
Same steps as the answer above, but on the M1 Macs, the settings looked like this:
GDAL_LIBRARY_PATH = "/opt/homebrew/lib/libgdal.dylib"
GEOS_LIBRARY_PATH = "/opt/homebrew/lib/libgeos_c.dylib"
(Didn't need PROJ because I'm using "ENGINE": "django.contrib.gis.db.backends.mysql",

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f197e469a60>

hi guys i'm working in project with cms called tendenci which required to work with PostgreSQL and python django, I've been working on it on a virtual machine with Ubuntu and when i tried to migrate to production server (with Ubuntu also) i faced a lot of issues the last is migrate the db, actually i did all the required steps but it still showing an error when i try to run the server
this is the command that i run
python manage.py runserver
this is the error that i get
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7fadbc707a60>
Traceback (most recent call last):
File "/srv/mysite/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
psycopg2.ProgrammingError: relation "site_settings_setting" does not exist
LINE 1: SELECT (1) AS "a" FROM "site_settings_setting" WHERE ("site_...
^
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/srv/mysite/lib/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/srv/mysite/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 124, in inner_run
self.check(display_num_errors=True)
File "/srv/mysite/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/srv/mysite/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/srv/mysite/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/srv/mysite/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "/srv/mysite/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/srv/mysite/lib/python3.6/site-packages/django/urls/resolvers.py", line 256, in check
for pattern in self.url_patterns:
File "/srv/mysite/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/srv/mysite/lib/python3.6/site-packages/django/urls/resolvers.py", line 407, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/srv/mysite/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/srv/mysite/lib/python3.6/site-packages/django/urls/resolvers.py", line 400, in urlconf_module
return import_module(self.urlconf_name)
File "/srv/mysite/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/var/www/clients/client1/web1/web/mysite/conf/urls.py", line 6, in <module>
from tendenci.urls import handler500 # noqa: F401
File "/srv/mysite/lib/python3.6/site-packages/tendenci/urls.py", line 18, in <module>
registry_autodiscover()
File "/srv/mysite/lib/python3.6/site-packages/tendenci/apps/registry/register.py", line 21, in autodiscover
import_module('%s.app_registry' % app)
File "/srv/mysite/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/srv/mysite/lib/python3.6/site-packages/tendenci/apps/entities/app_registry.py", line 18, in <module>
site.register(Entity, EntityRegistry)
File "/srv/mysite/lib/python3.6/site-packages/tendenci/apps/registry/sites.py", line 157, in register
cache_reg_apps(self.get_registered_apps())
File "/srv/mysite/lib/python3.6/site-packages/tendenci/apps/registry/sites.py", line 177, in get_registered_apps
apps = RegisteredApps(self._registry)
File "/srv/mysite/lib/python3.6/site-packages/tendenci/apps/registry/sites.py", line 44, in __init__
if check_setting(*setting_tuple):
File "/srv/mysite/lib/python3.6/site-packages/tendenci/apps/site_settings/utils.py", line 156, in check_setting
scope_category=scope_category, name=name).exists()
File "/srv/mysite/lib/python3.6/site-packages/django/db/models/query.py", line 673, in exists
return self.query.has_results(using=self.db)
File "/srv/mysite/lib/python3.6/site-packages/django/db/models/sql/query.py", line 517, in has_results
return compiler.has_results()
File "/srv/mysite/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 858, in has_results
return bool(self.execute_sql(SINGLE))
File "/srv/mysite/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 899, in execute_sql
raise original_exception
File "/srv/mysite/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 889, in execute_sql
cursor.execute(sql, params)
File "/srv/mysite/lib/python3.6/site-packages/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/srv/mysite/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/srv/mysite/lib/python3.6/site-packages/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/srv/mysite/lib/python3.6/site-packages/django/utils/six.py", line 685, in reraise
raise value.with_traceback(tb)
File "/srv/mysite/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: relation "site_settings_setting" does not exist
LINE 1: SELECT (1) AS "a" FROM "site_settings_setting" WHERE ("site_...
i don't know if there is a problem with the db or there is somthing else

dateutil conflict with django

Here is the question: an error occurs when I import pandas:
dateutil: No module named 'dateutil'
So i installed dateutil, which is successfully installed, with pip:
pip3 install python-dateutil
but when i run my django project i got error like this:
Watching for file changes with StatReloader
Performing system checks...
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/lib/python3.5/dist-packages/django/urls/resolvers.py", line 573, in url_patterns
iter(patterns)
TypeError: 'module' object is not iterable
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.5/dist-packages/django/utils/autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 377, in _run_checks
return checks.run_checks(**kwargs)
File "/usr/local/lib/python3.5/dist-packages/django/core/checks/registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "/usr/local/lib/python3.5/dist-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/usr/local/lib/python3.5/dist-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/usr/local/lib/python3.5/dist-packages/django/urls/resolvers.py", line 398, in check
for pattern in self.url_patterns:
File "/usr/local/lib/python3.5/dist-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.5/dist-packages/django/urls/resolvers.py", line 580, in url_patterns
raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf 'django_project.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/usr/local/lib/python3.5/dist-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/commands/runserver.py", line 60, in execute
super().execute(*args, **options)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/commands/runserver.py", line 95, in handle
self.run(**options)
File "/usr/local/lib/python3.5/dist-packages/django/core/management/commands/runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "/usr/local/lib/python3.5/dist-packages/django/utils/autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/django/utils/autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "/usr/local/lib/python3.5/dist-packages/django/utils/autoreload.py", line 272, in run
get_resolver().urlconf_module
File "/usr/local/lib/python3.5/dist-packages/django/utils/functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/usr/local/lib/python3.5/dist-packages/django/urls/resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python3.5/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 986, in _gcd_import
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 665, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/murphy/django_project/django_project/urls.py", line 22, in <module>
from app1.views import IndexView, GLCView
File "/home/murphy/django_project/apps/app1/views.py", line 15, in <module>
import myvariant
File "/usr/local/lib/python3.5/dist-packages/myvariant/__init__.py", line 4, in <module>
from biothings_client import get_client
File "/usr/local/lib/python3.5/dist-packages/biothings_client/__init__.py", line 10, in <module>
from .base import (BiothingClient, __version__, alwayslist, caching_avail,
File "/usr/local/lib/python3.5/dist-packages/biothings_client/base.py", line 18, in <module>
from pandas import DataFrame
File "/usr/local/lib/python3.5/dist-packages/pandas/__init__.py", line 55, in <module>
from pandas.core.api import (
File "/usr/local/lib/python3.5/dist-packages/pandas/core/api.py", line 5, in <module>
from pandas.core.arrays.integer import (
File "/usr/local/lib/python3.5/dist-packages/pandas/core/arrays/__init__.py", line 1, in <module>
from .array_ import array # noqa: F401
File "/usr/local/lib/python3.5/dist-packages/pandas/core/arrays/array_.py", line 7, in <module>
from pandas.core.dtypes.common import (
File "/usr/local/lib/python3.5/dist-packages/pandas/core/dtypes/common.py", line 11, in <module>
from pandas.core.dtypes.dtypes import (
File "/usr/local/lib/python3.5/dist-packages/pandas/core/dtypes/dtypes.py", line 53, in <module>
class Registry:
File "/usr/local/lib/python3.5/dist-packages/pandas/core/dtypes/dtypes.py", line 84, in Registry
self, dtype: Union[Type[ExtensionDtype], str]
File "/usr/lib/python3.5/typing.py", line 552, in __getitem__
dict(self.__dict__), parameters, _root=True)
File "/usr/lib/python3.5/typing.py", line 512, in __new__
for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
File "/usr/lib/python3.5/typing.py", line 512, in <genexpr>
for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
File "/usr/lib/python3.5/typing.py", line 1077, in __subclasscheck__
if super().__subclasscheck__(cls):
File "/usr/lib/python3.5/abc.py", line 225, in __subclasscheck__
for scls in cls.__subclasses__():
TypeError: descriptor '__subclasses__' of 'type' object needs an argument
There are 2 line relating to my project, which use a biological packages, I don't know if that's the reason.
To continue my django project, i have to uninstall dateutil as a temporary solution.
How can I solve this problem?
This problem has been solved. It turns out I did not describe what the real problem is, it's pandas(0.25.3) conflict with django(2.2) instead of dateutil. I reinstalled a old version of pandas(0.24.1) and it can work. I don't know why, but it works. Hope this can give other people a hint when they have the same question.

Categories