Problem when import ModelResource from tastypie.resources - python

I am new to Django and I want to create some API with tastypie, but when I import ModelResource from tastypie.resource I face with error :/
I just do this:
from tastypie.resources import ModelResource
I get this error:
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 954, in _bootstrap_inner
self.run()
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 110, in inner_run
autoreload.raise_last_exception()
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/utils/autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/core/management/__init__.py", line 375, in execute
autoreload.check_errors(django.setup)()
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/utils/autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/apps/registry.py", line 114, in populate
app_config.import_models()
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/apps/config.py", line 301, in import_models
self.models_module = import_module(models_module_name)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "/Users/macbook/Documents/PriceList/api/models.py", line 4, in <module>
from tastypie.resources import ModelResource
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/tastypie/resources.py", line 22, in <module>
from django.contrib.gis.db.models.fields import GeometryField
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/contrib/gis/db/models/__init__.py", line 3, in <module>
import django.contrib.gis.db.models.functions # NOQA
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/contrib/gis/db/models/functions.py", line 3, in <module>
from django.contrib.gis.db.models.fields import BaseSpatialField, GeometryField
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/contrib/gis/db/models/fields.py", line 3, in <module>
from django.contrib.gis import forms, gdal
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/contrib/gis/forms/__init__.py", line 3, in <module>
from .fields import ( # NOQA
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/contrib/gis/forms/fields.py", line 2, in <module>
from django.contrib.gis.gdal import GDALException
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/contrib/gis/gdal/__init__.py", line 28, in <module>
from django.contrib.gis.gdal.datasource import DataSource
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/contrib/gis/gdal/datasource.py", line 40, in <module>
from django.contrib.gis.gdal.driver import Driver
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/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 "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/contrib/gis/gdal/prototypes/ds.py", line 9, in <module>
from django.contrib.gis.gdal.libgdal import GDAL_VERSION, lgdal
File "/Users/macbook/.local/share/virtualenvs/PriceList-ofEay4QN/lib/python3.9/site-packages/django/contrib/gis/gdal/libgdal.py", line 50, in <module>
lgdal = CDLL(lib_path)
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/ctypes/__init__.py", line 374, in __init__
self._handle = _dlopen(self._name, mode)
OSError: dlopen(/usr/local/lib/libgdal.dylib, 6): Symbol not found: _curl_multi_poll
Referenced from: /usr/local/lib/libgdal.dylib
Expected in: /usr/lib/libcurl.4.dylib
in /usr/local/lib/libgdal.dylib
The current Django version is 3.2 . I try to install the latest version of Django (4.1.1) to fix the error but it doesn't work. The version of tastypie is 0.14.4.
If it helps I use python version 3.9.
Thanks

Problem solved :/
There was a problem with GDAL on my system and the Django version.
I just run this command in my terminal:
brew link --overwrite gdal
and downgrade the Django version to 3.2 .

Related

pip freeze throws an exception

I am using Python 3.11.0 on Windows 10. I was able to successfully create a virtual environment with a requirements file. My pip.ini has references to my company's repository.
When I ran pip freeze it threw an exception.
My minimal requirements file is as follows:
asc-security-python
derf-api-catalog
flask
flask-restx
gevent
openpyxl
pandas
pytest
pytest-xdist
requests-negotiate-sspi
sqlalchemy-pyodbc-mssql
waitress
xlsxwriter
The detailed steps are as follows:
%USERPROFILE%\Python\python -m venv %USERPROFILE%\envs\MyEnv
%USERPROFILE%\envs\MyEnv\Scripts\activate
cd %USERPROFILE%\MyProject
pip install -r myrequirements.txt
pip freeze
The exception thrown is as follows:
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\johndoe\envs\MyEnv\Scripts\pip.exe\__main__.py", line 4, in <module>
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
from pip._internal.cli.autocompletion import autocomplete
File "C:\Users\johndoe\envs\MyEnv\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\johndoe\envs\MyEnv\Lib\site-packages\pip\_internal\cli\main_parser.py", line 9, in <module>
from pip._internal.build_env import get_runnable_pip
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_internal\build_env.py", line 20, in <module>
from pip._internal.cli.spinners import open_spinner
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_internal\cli\spinners.py", line 9, in <module>
from pip._internal.utils.logging import get_indentation
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_internal\utils\logging.py", line 29, in <module>
from pip._internal.utils.misc import ensure_dir
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_internal\utils\misc.py", line 41, in <module>
from pip._internal.exceptions import CommandError
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_internal\exceptions.py", line 13, in <module>
from pip._vendor.requests.models import Request, Response
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_vendor\requests\__init__.py", line 149, in <module>
from . import packages, utils
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\pip\_vendor\requests\utils.py", line 24, in <module>
from . import certs
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\wrapt\importer.py", line 177, in _exec_module
notify_module_loaded(module)
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
return wrapped(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\certifi_win32\wrapt_pip.py", line 35, in apply_patches
import certifi
File "<frozen importlib._bootstrap>", line 1178, in _find_and_load
File "<frozen importlib._bootstrap>", line 1149, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 690, in _load_unlocked
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\wrapt\importer.py", line 177, in _exec_module
notify_module_loaded(module)
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\wrapt\decorators.py", line 470, in _synchronized
return wrapped(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\wrapt\importer.py", line 136, in notify_module_loaded
hook(module)
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\certifi_win32\wrapt_certifi.py", line 20, in apply_patches
certifi_win32.wincerts.CERTIFI_PEM = certifi.where()
^^^^^^^^^^^^^^^
File "C:\Users\johndoe\envs\MyEnv\Lib\site-packages\certifi\core.py", line 37, in where
_CACERT_PATH = str(_CACERT_CTX.__enter__())
^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\johndoe\Python\Lib\contextlib.py", line 137, in __enter__
return next(self.gen)
^^^^^^^^^^^^^^
File "C:\Users\johndoe\Python\Lib\importlib\resources\_common.py", line 80, in _tempfile
os.write(fd, reader())
^^^^^^^^
File "C:\Users\johndoe\Python\Lib\importlib\resources\abc.py", line 76, in read_bytes
with self.open('rb') as strm:
^^^^^^^^^^^^^^^
File "C:\Users\johndoe\Python\Lib\importlib\resources\_adapters.py", line 141, in open
raise FileNotFoundError("Can't open orphan path")
FileNotFoundError: Can't open orphan path
Is there a fix for the issue that will allow me to generate a detailed requirements.txt showing all dependencies?

ImportError: libssl.so.1.0.0: cannot open shared object file: No such file or directory

When running a project via pipenv, I get the following stacktrace. As I typically do not work with pipenv and cookiecutter projects, I have been struggling to fix it. Any help is appreciated. In case it matters, it is this project that I am trying to build and launch.
➜ project-shop git:(master) ✗ pipenv run ./manage.py runserver
[2022-11-04 13:08:19,329 autoreload] INFO: Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "/home/user/miniconda3/lib/python3.7/threading.py", line 917, in _bootstrap_inner
self.run()
File "/home/user/miniconda3/lib/python3.7/threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "/home/user/.local/share/virtualenvs/project-shop-d1PiLiCc/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/user/.local/share/virtualenvs/project-shop-d1PiLiCc/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "/home/user/.local/share/virtualenvs/project-shop-d1PiLiCc/lib/python3.7/site-packages/django/utils/autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "/home/user/.local/share/virtualenvs/project-shop-d1PiLiCc/lib/python3.7/site-packages/django/core/management/__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "/home/user/.local/share/virtualenvs/project-shop-d1PiLiCc/lib/python3.7/site-packages/django/utils/autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "/home/user/.local/share/virtualenvs/project-shop-d1PiLiCc/lib/python3.7/site-packages/django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/user/.local/share/virtualenvs/project-shop-d1PiLiCc/lib/python3.7/site-packages/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "/home/user/.local/share/virtualenvs/project-shop-d1PiLiCc/lib/python3.7/site-packages/django/apps/config.py", line 90, in create
module = import_module(entry)
File "/home/user/miniconda3/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/user/.local/share/virtualenvs/project-shop-d1PiLiCc/lib/python3.7/site-packages/django_elasticsearch_dsl/__init__.py", line 5, in <module>
from .documents import Document # noqa
File "/home/user/.local/share/virtualenvs/project-shop-d1PiLiCc/lib/python3.7/site-packages/django_elasticsearch_dsl/documents.py", line 8, in <module>
from elasticsearch.helpers import bulk, parallel_bulk
File "/home/user/.local/share/virtualenvs/project-shop-d1PiLiCc/lib/python3.7/site-packages/elasticsearch/__init__.py", line 36, in <module>
from .client import Elasticsearch
File "/home/user/.local/share/virtualenvs/project-shop-d1PiLiCc/lib/python3.7/site-packages/elasticsearch/client/__init__.py", line 23, in <module>
from ..transport import Transport, TransportError
File "/home/user/.local/share/virtualenvs/project-shop-d1PiLiCc/lib/python3.7/site-packages/elasticsearch/transport.py", line 26, in <module>
from .connection import Urllib3HttpConnection
File "/home/user/.local/share/virtualenvs/project-shop-d1PiLiCc/lib/python3.7/site-packages/elasticsearch/connection/__init__.py", line 20, in <module>
from .http_urllib3 import Urllib3HttpConnection, create_ssl_context
File "/home/user/.local/share/virtualenvs/project-shop-d1PiLiCc/lib/python3.7/site-packages/elasticsearch/connection/http_urllib3.py", line 18, in <module>
import ssl
File "/home/user/miniconda3/lib/python3.7/ssl.py", line 98, in <module>
import _ssl # if we can't import it, let the error propagate
ImportError: libssl.so.1.0.0: cannot open shared object file: No such file or directory
add :
deb http://security.ubuntu.com/ubuntu xenial-security main
in /etc/apt/source.list
then ==> apt-get update ,
apt install libssl1.0.0

I get an error when I install the SWITIFY package, does anyone know what it means?

when I install the package sweetify, I get the following error
Does anyone know what the reason is?
I went through all the steps that were in the main dock
Traceback (most recent call last):
File "C:\Program Files\Python38\lib\threading.py", line 932, in _bootstrap_inner
self.run()
File "C:\Program Files\Python38\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run
autoreload.raise_last_exception()
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\core\management\__init__.py", line 398, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\apps\config.py", line 228, in create
import_module(entry)
File "C:\Program Files\Python38\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 848, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\sweetify\__init__.py", line 1, in <module>
from .sweetify import *
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\sweetify\sweetify.py", line 5, in <module>
from .encoder import LazyEncoder
File "C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\sweetify\encoder.py", line 2, in <module>
from django.utils.encoding import force_text
ImportError: cannot import name 'force_text' from 'django.utils.encoding' (C:\Users\nahid\PycharmProjects\fitshow\venv\lib\site-packages\django\utils\encoding.py)
Looks like sweetify is not compatible with Django 4.0. See the changelog: https://docs.djangoproject.com/en/4.0/releases/4.0/#features-removed-in-4-0
django.utils.encoding.force_text() and smart_text() are removed.
Try with older version of django, I recommend 3.2.13 :)
this error is coming from django v4 . according to django documentation django.utils.encoding.force_text() and smart_text() are removed.
possible solution :
1 - using Django version 4> add in settings.py :
import django
from django.utils.encoding import force_str
django.utils.encoding.force_text = force_str
Downgrade your django version to django<=3

Error while trying to run dsample project with django

I am getting the error while trying to run a project in django.
The error is :
Watching for file changes with StatReloader Exception in thread
django-main-thread: Traceback (most recent call last):
I have installed it in the virtual environment.
The detailed error included below
(venv) D:\djEnv\t2>python3 manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "c:\programdata\anaconda3\Lib\threading.py", line 926, in _bootstrap_inner
self.run()
File "c:\programdata\anaconda3\Lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "D:\djEnv\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "D:\djEnv\venv\lib\site-packages\django\core\management\commands\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "D:\djEnv\venv\lib\site-packages\django\utils\autoreload.py", line 76, in raise_last_exception
raise _exception[1]
File "D:\djEnv\venv\lib\site-packages\django\core\management\__init__.py", line 357, in execute
autoreload.check_errors(django.setup)()
File "D:\djEnv\venv\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
fn(*args, **kwargs)
File "D:\djEnv\venv\lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "D:\djEnv\venv\lib\site-packages\django\apps\registry.py", line 114, in populate
app_config.import_models()
File "D:\djEnv\venv\lib\site-packages\django\apps\config.py", line 211, in import_models
self.models_module = import_module(models_module_name)
File "D:\djEnv\venv\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "D:\djEnv\venv\lib\site-packages\django\contrib\auth\models.py", line 2, in <module>
from django.contrib.auth.base_user import AbstractBaseUser, BaseUserManager
File "D:\djEnv\venv\lib\site-packages\django\contrib\auth\base_user.py", line 47, in <module>
class AbstractBaseUser(models.Model):
File "D:\djEnv\venv\lib\site-packages\django\db\models\base.py", line 121, in __new__
new_class.add_to_class('_meta', Options(meta, app_label))
File "D:\djEnv\venv\lib\site-packages\django\db\models\base.py", line 325, in add_to_class
value.contribute_to_class(cls, name)
File "D:\djEnv\venv\lib\site-packages\django\db\models\options.py", line 208, in contribute_to_class
self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
File "D:\djEnv\venv\lib\site-packages\django\db\__init__.py", line 28, in __getattr__
return getattr(connections[DEFAULT_DB_ALIAS], item)
File "D:\djEnv\venv\lib\site-packages\django\db\utils.py", line 207, in __getitem__
backend = load_backend(db['ENGINE'])
File "D:\djEnv\venv\lib\site-packages\django\db\utils.py", line 111, in load_backend
return import_module('%s.base' % backend_name)
File "D:\djEnv\venv\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "D:\djEnv\venv\lib\site-packages\django\db\backends\sqlite3\base.py", line 14, in <module>
from sqlite3 import dbapi2 as Database
File "c:\programdata\anaconda3\Lib\sqlite3\__init__.py", line 23, in <module>
from sqlite3.dbapi2 import *
File "c:\programdata\anaconda3\Lib\sqlite3\dbapi2.py", line 27, in <module>
from _sqlite3 import *
ImportError: DLL load failed: The specified module could not be found.
The terminal keeps on buffering after this
Following the answer linked by #bmons, I updated my %PATH% to include
C:\ProgramData\Anaconda3\envs\py36\Lib\site-packages\pythonwin
C:\ProgramData\Anaconda3\envs\py36\Lib\sqlite3
Directions for updating the %PATH% variables on windows10: https://helpdeskgeek.com/windows-10/add-windows-path-environment-variable/

Getting cannot import name urlresolvers error when running manage.py

I understand that I asked this question an hour or so ago, but it was closed as a duplicate. I have however tried the solutions suggested in the other question, including upgrading my django, making changes to models and utils.py
#from
from django.core import urlresolvers
#to
from django.urls import reverse
but still getting 'cannot import name urlresolvers' as an error when I try run manage.py runserver.
This is the full error
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\threading.py", line 926, in _bootstrap_inne
r
self.run()
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py",
line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\comman
ds\runserver.py", line 109, in inner_run
autoreload.raise_last_exception()
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py",
line 77, in raise_last_exception
raise _exception[1]
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\core\management\__init
__.py", line 337, in execute
autoreload.check_errors(django.setup)()
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\utils\autoreload.py",
line 54, in wrapper
fn(*args, **kwargs)
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\__init__.py", line 24,
in setup
apps.populate(settings.INSTALLED_APPS)
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\registry.py", lin
e 114, in populate
app_config.import_models()
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\django\apps\config.py", line
211, in import_models
self.models_module = import_module(models_module_name)
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\importlib\__init__.py", line 127, in import
_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\allauth\account\models.py", l
ine 17, in <module>
from .utils import user_email
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\allauth\account\utils.py", li
ne 30, in <module>
from ..utils import (import_callable, valid_email_or_none,
File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\allauth\utils.py", line 8, in
<module>
from django.core import urlresolvers
ImportError: cannot import name 'urlresolvers' from 'django.core' (C:\Users\User\AppData\Local\Programs\Pyth
on\Python37\lib\site-packages\django\core\__init__.py)
Just to reiterate- I have tried the solutions suggested here -> ImportError: No module named 'django.core.urlresolvers'

Categories

Resources