XMLParser.__init__() takes 1 positional argument but 4 were given - python-3.x

I am getting this error while running the below command:-
Python version=3.10.8
Django version=2.1
openpyxl=2.6.2
python manage.py runserver 127.0.0.1:8000
Error:-
Exception ignored in thread started by: <function check_errors.<locals>.wrapper at 0x118793400>
Traceback (most recent call last):
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/utils/autoreload.py", line 248, in raise_last_exception
raise _exception[1]
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/core/management/__init__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/apps/registry.py", line 89, in populate
app_config = AppConfig.create(entry)
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/opt/homebrew/Cellar/python#3.10/3.10.8/Frameworks/Python.framework/Versions/3.10/lib/python3.10/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 "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/tablib/__init__.py", line 3, in <module>
from tablib.core import (
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/tablib/core.py", line 15, in <module>
from tablib import formats
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/tablib/formats/__init__.py", line 12, in <module>
from . import _xlsx as xlsx
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/tablib/formats/_xlsx.py", line 14, in <module>
import openpyxl
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/__init__.py", line 6, in <module>
from openpyxl.workbook import Workbook
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/workbook/__init__.py", line 5, in <module>
from .workbook import Workbook
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/workbook/workbook.py", line 8, in <module>
from openpyxl.worksheet.worksheet import Worksheet
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/worksheet/worksheet.py", line 30, in <module>
from openpyxl.cell import Cell, MergedCell
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/cell/__init__.py", line 4, in <module>
from .cell import Cell, WriteOnlyCell, MergedCell
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/cell/cell.py", line 52, in <module>
from openpyxl.styles.styleable import StyleableObject
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/styles/styleable.py", line 11, in <module>
from .builtins import styles
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/openpyxl/styles/builtins.py", line 1347, in <module>
('Normal', NamedStyle.from_tree(fromstring(normal))),
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/defusedxml/common.py", line 113, in fromstring
parser = DefusedXMLParser(target=_TreeBuilder(),
File "/Users/chandanvarma/Desktop/project/retailer-backend/venv/lib/python3.10/site-packages/defusedxml/ElementTree.py", line 68, in __init__
_XMLParser.__init__(self, html, target, encoding)
TypeError: XMLParser.__init__() takes 1 positional argument but 4 were given
I couldn't understand the exact issue behind this, If anyone has an idea how to resolve, please feel free share his/her suggestions.

The html argument of XMLParser() is deprecated in python3.7. You must to upgrade openpyxl to a newest version (at least 3.0.0):
https://openpyxl.readthedocs.io/en/stable/changes.html#id80

Related

importlib has some questions result to my anaconda and jupternotebook even pip didn't work

when i opened jupternotebook in anaconda3, it showed that:
File "C:\ProgramData\Anaconda3\cwp.py", line 9, in <module>
from menuinst.knownfolders import FOLDERID, get_folder_path, PathNotFoundException
File "C:\ProgramData\Anaconda3\lib\site-packages\menuinst\__init__.py", line 23, in <module>
from .win32 import Menu, ShortCut
File "C:\ProgramData\Anaconda3\lib\site-packages\menuinst\win32.py", line 11, in <module>
import pywintypes
File "C:\ProgramData\Anaconda3\lib\site-packages\win32\lib\pywintypes.py", line 2, in <module>
import imp, sys, os
File "C:\ProgramData\Anaconda3\lib\imp.py", line 23, in <module>
from importlib import util
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 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 857, in get_code
File "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
then i guessed it may be importlib's error but when i wanted to check the version of this package, i found i can't use the command below
PS C:\Users\Jayus> python -m pip list
Could not import runpy module
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\runpy.py", line 15, in <module>
import importlib.util
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 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 857, in get_code
File "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
PS C:\Users\Jayus> pip list
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\pip-script.py", line 6, in <module>
from pip._internal.cli.main import main
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\cli\main.py", line 10, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\cli\autocompletion.py", line 9, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\cli\main_parser.py", line 7, in <module>
from pip._internal.cli import cmdoptions
File "C:\ProgramData\Anaconda3\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 19, in <module>
from distutils.util import strtobool
File "C:\ProgramData\Anaconda3\lib\distutils\util.py", line 9, in <module>
import importlib.util
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 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 857, in get_code
File "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
it clearly is the importlib's error but how can i fix it? I have tried install it in anaconda3 and the pycharm, but i can not even open it, when i use the command below, error again.
PS C:\Users\Jayus> conda activate base
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\_vendor\five.py", line 47, in <module>
reload = reload # noqa
NameError: name 'reload' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\conda-script.py", line 12, in <module>
sys.exit(main())
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 151, in main
from ..exceptions import conda_exception_handler
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\exceptions.py", line 19, in <module>
from ._vendor.auxlib.entity import EntityEncoder
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\entity.py", line 253, in <module>
from .collection import AttrDict, frozendict, make_immutable
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\collection.py", line 10, in <module>
from .compat import isiterable, iteritems, odict, text_type
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\compat.py", line 9, in <module>
from ._vendor.five import WhateverIO as StringIO, with_metaclass
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\_vendor\five.py", line 49, in <module>
from imp import reload # noqa
File "C:\ProgramData\Anaconda3\lib\imp.py", line 23, in <module>
from importlib import util
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 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 857, in get_code
File "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
base is my env name, and it is the default env
by the way, i can not open anaconda3 powershell prompt and the navigator, that is the result.
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\_vendor\five.py", line 47, in <module>
reload = reload # noqa
NameError: name 'reload' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 139, in main
from ..activate import main as activator_main
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\activate.py", line 20, in <module>
from ._vendor.auxlib.compat import Utf8NamedTemporaryFile
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\compat.py", line 9, in <module>
from ._vendor.five import WhateverIO as StringIO, with_metaclass
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\_vendor\five.py", line 49, in <module>
from imp import reload # noqa
File "C:\ProgramData\Anaconda3\lib\imp.py", line 23, in <module>
from importlib import util
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 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 857, in get_code
File "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\_vendor\five.py", line 47, in <module>
reload = reload # noqa
NameError: name 'reload' is not defined
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\ProgramData\Anaconda3\Scripts\conda-script.py", line 12, in <module>
sys.exit(main())
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 147, in main
init_loggers()
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\cli\main.py", line 56, in init_loggers
from ..gateways.logging import initialize_logging, set_verbosity
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\gateways\logging.py", line 14, in <module>
from ..common.io import attach_stderr_handler
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\common\io.py", line 31, in <module>
from .._vendor.auxlib.logz import NullHandler
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\logz.py", line 9, in <module>
from .compat import text_type
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\compat.py", line 9, in <module>
from ._vendor.five import WhateverIO as StringIO, with_metaclass
File "C:\ProgramData\Anaconda3\lib\site-packages\conda\_vendor\auxlib\_vendor\five.py", line 49, in <module>
from imp import reload # noqa
File "C:\ProgramData\Anaconda3\lib\imp.py", line 23, in <module>
from importlib import util
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 724, in exec_module
File "<frozen importlib._bootstrap_external>", line 857, in get_code
File "<frozen importlib._bootstrap_external>", line 525, in _compile_bytecode
ValueError: bad marshal data (unknown type code)
Invoke-Expression : 无法将参数绑定到参数“Command”,因为该参数为空字符串。
所在位置 C:\ProgramData\Anaconda3\shell\condabin\Conda.psm1:101 字符: 36
+ Invoke-Expression -Command $activateCommand;
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Invoke-Expression],ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.Invo
keExpressionCommand
i can still use the python command,but that's it,that's all i can use maybe. thank you for all if you can help me.
I solved this, maybe not solve, i just reinstalled it....

pip gives an AttributeError: module 'typing' has no attribute '_ClassVar'

I'm having trouble with pip on my Windows 10 system. If I try to do anything with pip (such as "pip -h") I get the following:
D:\Downloads\pip\pip-22.0.4>pip -h
Traceback (most recent call last):
File "C:\Program Files\Python310\Scripts\pip-script.py", line 33, in <module>
sys.exit(load_entry_point('pip==22.0.4', 'console_scripts', 'pip')())
File "C:\Program Files\Python310\Scripts\pip-script.py", line 25, in importlib_load_entry_point
return next(matches).load()
File "C:\Program Files\Python310\lib\importlib\metadata\__init__.py", line 171, in load
module = import_module(match.group('module'))
File "C:\Program Files\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 "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
from pip._internal.cli.main_parser import create_main_parser
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
from pip._internal.cli import cmdoptions
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_internal\cli\cmdoptions.py", line 23, in <module>
from pip._internal.cli.parser import ConfigOptionParser
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_internal\cli\parser.py", line 12, in <module>
from pip._internal.configuration import Configuration, ConfigurationError
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_internal\configuration.py", line 20, in <module>
from pip._internal.exceptions import (
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_internal\exceptions.py", line 14, in <module>
from pip._vendor.rich.console import Console, ConsoleOptions, RenderResult
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_vendor\rich\console.py", line 55, in <module>
from .pretty import Pretty, is_expandable
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python39\Lib\site-packages\pip\_vendor\rich\pretty.py", line 366, in <module>
class Node:
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python36\Lib\site-packages\dataclasses.py", line 958, in dataclass
return wrap(_cls)
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python36\Lib\site-packages\dataclasses.py", line 950, in wrap
return _process_class(cls, init, repr, eq, order, unsafe_hash, frozen)
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python36\Lib\site-packages\dataclasses.py", line 800, in _process_class
cls_fields = [_get_field(cls, name, type)
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python36\Lib\site-packages\dataclasses.py", line 800, in <listcomp>
cls_fields = [_get_field(cls, name, type)
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python36\Lib\site-packages\dataclasses.py", line 659, in _get_field
if (_is_classvar(a_type, typing)
File "C:\Users\jxcla\AppData\Local\Programs\Python\Python36\Lib\site-packages\dataclasses.py", line 550, in _is_classvar
return type(a_type) is typing._ClassVar
AttributeError: module 'typing' has no attribute '_ClassVar'. Did you mean: 'ClassVar'?
I'm not sure when this started happening and I've tried reinstalling pip in numerous ways, but no luck. Same error. I've searched for answers on the web, but nothing has fixed it for me.
I'm a bit of a noob when it comes to this, so it's entirely possible I've done something to gum up the works. Any help would be greatly appreciated.
John
This issue seems to be cropping up for me in a couple of my CI builds. One possible fix seems to be:
pip uninstall dataclasses -y
In my case, I don't know how dataclasses is getting installed (it's supposed to be a built-in not a dependency), but it failed last night when I unpinned the dependency scs.

FastApi uvicorn server not connecting to localhost

I am trying FASTAPI with the code below and localhost is not reachable with 127.0.0.1:8000 or localhost:8000 also. Tried setting with different port numbers also.
At the end it says
NameError: name '_TypeAliasForm' is not defined
This is on windows 10 with python 3.10
from fastapi import FastAPI
app = FastAPI()
#app.get("/")
async def root():
return {"message": "Hello World"}
PS G:\pyproj\fastapiex> uvicorn main:app --reload
←[32mINFO←[0m: Will watch for changes in these directories: ['G:\\pyproj\\fastapiex']
←[32mINFO←[0m: Uvicorn running on ←[1mhttp://127.0.0.1:8000←[0m (Press CTRL+C to quit)
←[32mINFO←[0m: Started reloader process [←[36m←[1m6936←[0m] using ←[36m←[1mwatchgod←[0m
Process SpawnProcess-1:
Traceback (most recent call last):
File "c:\users\jsl\appdata\local\programs\python\python310\lib\multiprocessing\process.py", line 315, in _bootstrap
self.run()
File "c:\users\jsl\appdata\local\programs\python\python310\lib\multiprocessing\process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\uvicorn\subprocess.py", line 76, in subprocess_started
target(sockets=sockets)
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\uvicorn\server.py", line 68, in run
return asyncio.run(self.serve(sockets=sockets))
File "c:\users\jsl\appdata\local\programs\python\python310\lib\asyncio\runners.py", line 44, in run
return loop.run_until_complete(main)
File "c:\users\jsl\appdata\local\programs\python\python310\lib\asyncio\base_events.py", line 641, in run_until_complete
return future.result()
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\uvicorn\server.py", line 76, in serve
config.load()
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\uvicorn\config.py", line 448, in load
self.loaded_app = import_from_string(self.app)
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\uvicorn\importer.py", line 21, in import_from_string
module = importlib.import_module(module_str)
File "c:\users\jsl\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 1049, in _gcd_import
File "<frozen importlib._bootstrap>", line 1026, in _find_and_load
File "<frozen importlib._bootstrap>", line 1005, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 698, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 832, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File ".\main.py", line 1, in <module>
from fastapi import FastAPI
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\fastapi\__init__.py", line 7, in <module>
from .applications import FastAPI as FastAPI
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\fastapi\applications.py", line 3, in <module>
from fastapi import routing
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\fastapi\routing.py", line 20, in <module>
from fastapi import params
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\fastapi\params.py", line 4, in <module>
from pydantic.fields import FieldInfo, Undefined
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\pydantic\__init__.py", line 2, in <module>
from . import dataclasses
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\pydantic\dataclasses.py", line 3, in <module>
from .class_validators import gather_all_validators
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\pydantic\class_validators.py", line 8, in <module>
from .errors import ConfigError
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\pydantic\errors.py", line 5, in <module>
from .typing import display_as_type
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\pydantic\typing.py", line 23, in <module>
from typing_extensions import Annotated, Literal
File "c:\users\jsl\appdata\local\programs\python\python310\lib\site-packages\typing_extensions.py", line 1786, in <module>
#_TypeAliasForm
NameError: name '_TypeAliasForm' is not defined

OSError: libgdal.so.27: cannot open shared object file: No such file or directory

I built a docker file that installs gdal and proj library on CentOS8.
After successfully installation of all dependencies, when i run my docker image i get OSError: libgdal.so.27: cannot open shared object file: No such file or directory.
Please how do i rectify this ?
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/usr/lib64/python3.6/threading.py", line 916, in _bootstrap_inner
self.run()
File "/usr/lib64/python3.6/threading.py", line 864, in run
self._target(*self._args, **self._kwargs)
File "/home/devuser/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/devuser/.local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "/home/devuser/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "/home/devuser/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "/home/devuser/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/devuser/.local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/devuser/.local/lib/python3.6/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/home/devuser/.local/lib/python3.6/site-packages/django/apps/config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "/usr/lib64/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 "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/auth/models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/auth/base_user.py", line 48, in <module>
class AbstractBaseUser(models.Model):
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/models/base.py", line 122, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/models/base.py", line 326, in add_to_class
value.contribute_to_class(cls, name)
File "/home/devuser/.local/lib/python3.6/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 "/home/devuser/.local/lib/python3.6/site-packages/django/db/__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/utils.py", line 214, in __getitem__
backend = load_backend(db['ENGINE'])
File "/home/devuser/.local/lib/python3.6/site-packages/django/db/utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
File "/usr/lib64/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/backends/postgis/base.py", line 6, in <module>
from .features import DatabaseFeatures
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/backends/postgis/features.py", line 1, in <module>
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/backends/base/features.py", line 3, in <module>
from django.contrib.gis.db import models
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/models/__init__.py", line 3, in <module>
import django.contrib.gis.db.models.functions # NOQA
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/models/functions.py", line 3, in <module>
from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/db/models/fields.py", line 3, in <module>
from django.contrib.gis import forms, gdal
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/forms/__init__.py", line 3, in <module>
from .fields import ( # NOQA
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/forms/fields.py", line 2, in <module>
from django.contrib.gis.gdal import GDALException
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/__init__.py", line 28, in <module>
from django.contrib.gis.gdal.datasource import DataSource
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/datasource.py", line 39, in <module>
from django.contrib.gis.gdal.driver import Driver
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/driver.py", line 5, in <module>
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module>
from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
File "/home/devuser/.local/lib/python3.6/site-packages/django/contrib/gis/gdal/libgdal.py", line 50, in <module>
lgdal = CDLL(lib_path)
File "/usr/lib64/python3.6/ctypes/__init__.py", line 343, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libgdal.so.27: cannot open shared object file: No such file or directory
What i've tried
DISCLAIMER: I really do not understand why i did all of these and i don't know what they mean. I just want to install gdal for geodjango
RUN echo /usr/local/lib >> /etc/ld.so.conf.d/usrlocal.conf
RUN touch /etc/ld.so.conf.d/libgdal-x86_64.conf
RUN echo "/usr/local/lib" >> /etc/ld.so.conf.d/libgdal-x86_64.conf
Django recommends doing this
RUN export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

Core API: AttributeError: module 'click' has no attribute 'style'

I am a beginner in Django REST framework and while going through this part of the tutorial I faced and error. I installed coreapi and did the desired changes to the code but when I try to run the server, I face this problem:
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7f6220bd6268>
Traceback (most recent call last):
File "/home/atenagm/.local/lib/python3.5/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/atenagm/.local/lib/python3.5/site-packages/django/core/management/commands/runserver.py", line 121, in inner_run
self.check(display_num_errors=True)
File "/home/atenagm/.local/lib/python3.5/site-packages/django/core/management/base.py", line 385, in check
include_deployment_checks=include_deployment_checks,
File "/home/atenagm/.local/lib/python3.5/site-packages/django/core/management/base.py", line 372, in _run_checks
return checks.run_checks(**kwargs)
File "/home/atenagm/.local/lib/python3.5/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/atenagm/.local/lib/python3.5/site-packages/django/core/checks/urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "/home/atenagm/.local/lib/python3.5/site-packages/django/core/checks/urls.py", line 24, in check_resolver
for pattern in resolver.url_patterns:
File "/home/atenagm/.local/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/atenagm/.local/lib/python3.5/site-packages/django/urls/resolvers.py", line 310, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/atenagm/.local/lib/python3.5/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/atenagm/.local/lib/python3.5/site-packages/django/urls/resolvers.py", line 303, 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/atenagm/tutorial/tutorial/tutorial/urls.py", line 21, in <module>
url(r'^', include('snippets.urls')),
File "/home/atenagm/.local/lib/python3.5/site-packages/django/conf/urls/__init__.py", line 50, in include
urlconf_module = import_module(urlconf_module)
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/atenagm/tutorial/tutorial/snippets/urls.py", line 2, in <module>
from snippets import views
File "/home/atenagm/tutorial/tutorial/snippets/views.py", line 2, in <module>
from snippets.serializers import SnippetSerializer, UserSerializer
File "/home/atenagm/tutorial/tutorial/snippets/serializers.py", line 1, in <module>
from rest_framework import serializers
File "/usr/local/lib/python3.5/dist-packages/rest_framework/serializers.py", line 30, in <module>
from rest_framework.compat import JSONField as ModelJSONField
File "/usr/local/lib/python3.5/dist-packages/rest_framework/compat.py", line 170, in <module>
import coreapi
File "/usr/local/lib/python3.5/dist-packages/coreapi/__init__.py", line 2, in <module>
from coreapi import auth, codecs, exceptions, transports, utils
File "/usr/local/lib/python3.5/dist-packages/coreapi/auth.py", line 1, in <module>
from coreapi.utils import domain_matches
File "/usr/local/lib/python3.5/dist-packages/coreapi/utils.py", line 2, in <module>
from coreapi.compat import string_types, text_type, urlparse, _TemporaryFileWrapper
File "/usr/local/lib/python3.5/dist-packages/coreapi/compat.py", line 56, in <module>
console_style = click.style
AttributeError: module 'click' has no attribute 'style'
I couldn't find any solution to this error. Any suggestions?

Resources