when using azure functions I have the problem that certain packages (e.g. azure.kusto.data) can not be installed from the init file.
My init file looks like this:
import datetime
import logging
from azure.kusto.data.helpers import dataframe_from_result_table
import azure.functions as func
def main(mytimer: func.TimerRequest) -> None:
utc_timestamp = datetime.datetime.utcnow().replace(
tzinfo=datetime.timezone.utc).isoformat()
if mytimer.past_due:
logging.info('The timer is past due!')
logging.info('Python timer trigger function ran at %s', utc_timestamp)
My requirements.txt file contains:
azure-functions
azure-kusto-data
The error message is the following:
Result: Failure
Exception: AssertionError:
Stack: File "C:\Users\hanft\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.9/WINDOWS/X64\azure_functions_worker\dispatcher.py", line 301, in _handle__function_load_request
func = loader.load_function(
File "C:\Users\hanft\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.9/WINDOWS/X64\azure_functions_worker\utils\wrappers.py", line 40, in call
return func(*args, **kwargs)
File "C:\Users\hanft\AppData\Roaming\npm\node_modules\azure-functions-core-tools\bin\workers\python\3.9/WINDOWS/X64\azure_functions_worker\loader.py", line 83, in load_function
mod = importlib.import_module(fullmodname)
File "C:\Users\hanft\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 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 855, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\hanft\Documents\azuretestneu\jobs_creator\__init__.py", line 3, in <module>
from azure.kusto.data.helpers import dataframe_from_result_table
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\azure\kusto\data\__init__.py", line 5, in <module>
from .client import KustoClient, KustoConnectionStringBuilder, ClientRequestProperties
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\azure\kusto\data\client.py", line 22, in <module>
from .security import _AadHelper
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\azure\kusto\data\security.py", line 5, in <module>
from ._token_providers import *
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\azure\kusto\data\_token_providers.py", line 10, in <module>
from azure.identity import ManagedIdentityCredential, AzureCliCredential
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\azure\identity\__init__.py", line 9, in <module>
from ._credentials import (
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\azure\identity\_credentials\__init__.py", line 5, in <module>
from .authorization_code import AuthorizationCodeCredential
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\azure\identity\_credentials\authorization_code.py", line 8, in <module>
from .._internal.aad_client import AadClient
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\azure\identity\_internal\__init__.py", line 50, in <module>
from .certificate_credential_base import CertificateCredentialBase
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\azure\identity\_internal\certificate_credential_base.py", line 11, in <module>
from .persistent_cache import load_service_principal_cache
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\azure\identity\_internal\persistent_cache.py", line 9, in <module>
import msal_extensions
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\msal_extensions\__init__.py", line 12, in <module>
from .cache_lock import CrossPlatLock
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\msal_extensions\cache_lock.py", line 5, in <module>
import portalocker
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\portalocker\__init__.py", line 4, in <module>
from . import portalocker
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\portalocker\portalocker.py", line 10, in <module>
import pywintypes
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\win32\lib\pywintypes.py", line 105, in <module>
__import_pywin32_system_module__("pywintypes", globals())
File "C:\Users\hanft\Documents\azuretestneu\.venv\lib\site-packages\win32\lib\pywintypes.py", line 99, in __import_pywin32_system_module__
assert sys.modules[modname] is not old_mod
When removing the line
from azure.kusto.data.helpers import dataframe_from_result_table
from the init file, everything works fine.
I tried reinstalling python and visual studio code.
Any help would be appreciated!
As the trace suggests, pywin32 is a transitive dependency of azure-identity, an authentication library azure-kusto-data uses (azure-sdk-for-python#19989 has more detail on the problem, if you're curious). The latest version of azure-identity (1.6.1) imports that dependency only when necessary, to implement an optional feature. Happily, azure-kusto-data doesn't use that feature, so you should be able to work around this by upgrading azure-identity.
Related
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
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.
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
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
I'm using python3.6 and Django2.0, but the code is supposed to be written in Django1.x. An error occurred when I tried to start the service. This is my first time to contact Django and I hope to get help.
It should be an error in the urls.py file
This is urls.py. This file in the book of .it's GitHub is https://github.com/ai2010/machine_learning_for_the_web/tree/master/chapter_7/server_movierecsys
#from django.conf.urls import patterns, include, url
from django.conf.urls import include, url
from django.contrib import admin
from books_recsys_app.api import UsersList
import books_recsys_app.views
import rest_framework_swagger
from books_recsys_app.views import home, auth, signout, rate_movie, movies_recs
from rest_framework_swagger.views import get_swagger_view
schema_view = get_swagger_view(title='API name')
urlpatterns = [
url(r'^docs/', schema_view)
]
urlpatterns += [
url(r'^$', home, name='home'),
url(r'^auth/', auth, name='auth'),
url(r'^signout/',signout,name='signout'),
url(r'^rate_movie/',rate_movie,name='rate_movie'),
url(r'^movies-recs/',movies_recs,name='movies_recs'),
url(r'^admin/', include(admin.site.urls)),
url(r'^users-list/',UsersList.as_view(),name='users-list')
]
This error Message,when I run "python3 manage.py runserver localhost:8000"
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x10b52abf8>
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/autoreload.py", line 225, in wrapper
fn(*args, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 379, in check
include_deployment_checks=include_deployment_checks,
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/management/base.py", line 366, in _run_checks
return checks.run_checks(**kwargs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/registry.py", line 71, in run_checks
new_errors = check(app_configs=app_configs)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 40, in check_url_namespaces_unique
all_namespaces = _load_all_namespaces(resolver)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/core/checks/urls.py", line 57, in _load_all_namespaces
url_patterns = getattr(resolver, 'url_patterns', [])
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 533, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/utils/functional.py", line 37, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/urls/resolvers.py", line 526, in urlconf_module
return import_module(self.urlconf_name)
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 978, in _gcd_import
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 655, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
File "/Users/changxuan/PycharmProjects/reconmendationSystem/server_movierecsys/server_movierecsys/urls.py", line 5, in <module>
import books_recsys_app.views
File "/Users/changxuan/PycharmProjects/reconmendationSystem/server_movierecsys/books_recsys_app/views.py", line 17, in <module>
from sklearn.feature_extraction.text import TfidfVectorizer
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/feature_extraction/__init__.py", line 10, in <module>
from . import text
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/feature_extraction/text.py", line 30, in <module>
from ..preprocessing import normalize
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/preprocessing/__init__.py", line 6, in <module>
from ._function_transformer import FunctionTransformer
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/preprocessing/_function_transformer.py", line 5, in <module>
from ..utils.testing import assert_allclose_dense_sparse
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/sklearn/utils/testing.py", line 26, in <module>
from urllib2 import urlopen
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/urllib2.py", line 220
raise AttributeError, attr
^
SyntaxError: invalid syntax
The error occurred because urllib2 was referenced in the sklearn library and datasets library. I'm just going to change the code in the file
Original 24-31 contents:
Try:
# Python 2
The from urllib2 import urlopen
The from urllib2 import HTTPError
Except ImportError:
# Python 3 +
The from urllib. Request the import urlopen
The from urllib. Error import HTTPError
Reason: the contents of urllib2 are removed because of an error in python3.x
Now:
# Python 3 +
The from urllib. Request the import urlopen
The from urllib. Error import HTTPError