how to solve Textblob import Exception in Django views - django

how to solve Textblob import Exception in Django views
from textblob import TextBlob
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\Zain Ul Abideen\AppData\Local\Programs\Python\Python310\lib\threading.py", line 1016, in _bootstrap_inner
self.run()
File "C:\Users\Zain Ul Abideen\AppData\Local\Programs\Python\Python310\lib\threading.py", line 953, in run
self._target(*self._args, **self._kwargs)
File "E:\small tools\venv\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "E:\small tools\venv\lib\site-packages\django\core\management\commands\runserver.py", line 134, in inner_run
self.check(display_num_errors=True)
File "E:\small tools\venv\lib\site-packages\django\core\management\base.py", line 475, in check
all_issues = checks.run_checks(
File "E:\small tools\venv\lib\site-packages\django\core\checks\registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "E:\small tools\venv\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "E:\small tools\venv\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
return check_method()
File "E:\small tools\venv\lib\site-packages\django\urls\resolvers.py", line 494, in check
for pattern in self.url_patterns:
File "E:\small tools\venv\lib\site-packages\django\utils\functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "E:\small tools\venv\lib\site-packages\django\urls\resolvers.py", line 715, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "E:\small tools\venv\lib\site-packages\django\utils\functional.py", line 57, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "E:\small tools\venv\lib\site-packages\django\urls\resolvers.py", line 708, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\Zain Ul Abideen\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "E:\small tools\mysite\mysite\urls.py", line 23, in <module>
path('api/',include('core.urls'))
File "E:\small tools\venv\lib\site-packages\django\urls\conf.py", line 38, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\Zain Ul Abideen\AppData\Local\Programs\Python\Python310\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 883, in exec_module
File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
File "E:\small tools\mysite\core\urls.py", line 2, in <module>
from . import views
File "E:\small tools\mysite\core\views.py", line 11, in <module>
from textblob import TextBlob
File "E:\small tools\venv\lib\site-packages\textblob\__init__.py", line 2, in <module>
from .blob import TextBlob, Word, Sentence, Blobber, WordList
File "E:\small tools\venv\lib\site-packages\textblob\blob.py", line 29, in <module>
import nltk
File "E:\small tools\venv\lib\site-packages\nltk\__init__.py", line 137, in <module>
from nltk.text import *
File "E:\small tools\venv\lib\site-packages\nltk\text.py", line 29, in <module>
from nltk.tokenize import sent_tokenize
File "E:\small tools\venv\lib\site-packages\nltk\tokenize\__init__.py", line 64, in <module>
from nltk.data import load
File "E:\small tools\venv\lib\site-packages\nltk\data.py", line 53, in <module>
from nltk import grammar, sem
File "E:\small tools\venv\lib\site-packages\nltk\sem\__init__.py", line 44, in <module>
from nltk.sem.boxer import Boxer
File "E:\small tools\venv\lib\site-packages\nltk\sem\boxer.py", line 40, in <module>
from nltk.sem.drt import (
File "E:\small tools\venv\lib\site-packages\nltk\sem\drt.py", line 43, in <module>
from tkinter import Canvas, Tk
ValueError: source code string cannot contain null bytes
I Tried to Restart the Server but still getting the same Exception then i restarted my computer then again same exception

Related

Django server won't load

strong text
I am trying to run my django server using the python manage.py runservercommand. Keep getting this error in my shell. The development server is refusing to load. The image is the error message I'm getting
This is the error gotten after running the stated command above
`Traceback (most recent call last):
File "manage.py", line 22, in <module>
main()
File "manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "C:\Users\MY PC\desktop\django_exp\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "C:\Users\MY PC\desktop\django_exp\lib\site-packages\django\core\management\__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Users\MY PC\desktop\django_exp\lib\site-packages\django\core\management\base.py", line 414, in run_from_argv
self.execute(*args, **cmd_options)
File "C:\Users\MY PC\desktop\django_exp\lib\site-packages\django\core\management\base.py", line 460, in execute
output = self.handle(*args, **options)
File "C:\Users\MY PC\desktop\django_exp\lib\site-packages\django\core\management\commands\check.py", line 76, in handle
self.check(
File "C:\Users\MY PC\desktop\django_exp\lib\site-packages\django\core\management\base.py", line 487, in check
all_issues = checks.run_checks(
File "C:\Users\MY PC\desktop\django_exp\lib\site-packages\django\core\checks\registry.py", line 88, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\MY PC\desktop\django_exp\lib\site-packages\django\core\checks\urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "C:\Users\MY PC\desktop\django_exp\lib\site-packages\django\core\checks\urls.py", line 24, in check_resolver
return check_method()
File "C:\Users\MY PC\desktop\django_exp\lib\site-packages\django\urls\resolvers.py", line 480, in check
for pattern in self.url_patterns:
File "C:\Users\MY PC\desktop\django_exp\lib\site-packages\django\utils\functional.py", line 49, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\MY PC\desktop\django_exp\lib\site-packages\django\urls\resolvers.py", line 696, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\MY PC\desktop\django_exp\lib\site-packages\django\utils\functional.py", line 49, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\MY PC\desktop\django_exp\lib\site-packages\django\urls\resolvers.py", line 689, in urlconf_module
return import_module(self.urlconf_name)
File "c:\users\my pc\anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\MY PC\desktop\django_exp\src\django_novice\django_novice\urls.py", line 22, in <module>
path('polls/', include('polls.urls')),
File "C:\Users\MY PC\desktop\django_exp\lib\site-packages\django\urls\conf.py", line 38, in include
urlconf_module = import_module(urlconf_module)
File "c:\users\my pc\anaconda3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 783, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\MY PC\desktop\django_exp\src\django_novice\polls\urls.py", line 19, in <module>
from . import views
File "C:\Users\MY PC\desktop\django_exp\src\django_novice\polls\views.py", line 1, in <module>
from curses.ascii import HT
File "c:\users\my pc\anaconda3\lib\curses\__init__.py", line 13, in <module>
from _curses import *
ModuleNotFoundError: No module named '_curses'`
The import of curses.ascii import HT in your polls/views.py can not be loaded. This seems be an issue with your current python environment setup.
Please see this questions for more dtails: ImportError: No module named '_curses' when trying to import blessings

ModuleNotFoundError: No module named 'blog.models'

I was experimenting with my database and made some errors and messed up the whole database. I deleted the database and created a new blank db. When I go to makemigrations i get the error
ModuleNotFoundError: No module named 'blog.models' refering to the line in my views.py where i import my models. I tried creating a a new project and moving the files over same error. Everything was working fine before I messed up the DB. Sorry for not a ton of information I dont know what the issue really is
error
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\threading.py", line 954, in _bootstrap_inner
self.run()
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\threading.py", line 892, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\commands\runserver.py", line 118, in inner_run
self.check(display_num_errors=True)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\management\base.py", line 419, in check
all_issues = checks.run_checks(
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\checks\registry.py", line 76, in run_checks
new_errors = check(app_configs=app_configs, databases=databases)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
return check_method()
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\resolvers.py", line 412, in check
for pattern in self.url_patterns:
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\resolvers.py", line 598, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\utils\functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\resolvers.py", line 591, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Users\user\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 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\usera\djangoproject\django_coreyYT\urls.py", line 37, in <module>
path('', include('blog.urls')),
File "C:\Users\usera\AppData\Local\Programs\Python\Python39\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "C:\Users\usera\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 790, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "C:\Users\usera\djangoproject\blog\urls.py", line 3, in <module>
from .views import PostDeleteView, ....... (all the models)
File "C:\Users\usera\djangoproject\blog\views.py", line 5, in <module>
from .forms import PostForm, .... (all the models)
File "C:\Users\usera\djangoproject\blog\forms.py", line 3, in <module>
from blog.models import Post ... (all the models)
ModuleNotFoundError: No module named 'blog.models'
update
I tried switching to my production DB and i am still getting the same error

Issues with pytz 2019.1, Django 2.2?

I noticed that my Django-server crashes when I update pytz==2018.7 to pytz==2019.1. The Pytz library is in charge for all Timezone calculations. I ask myself if something changed and where I can find a changelog?
I did not change anything time related in my Django project and when I go back to pytz==2018.7 everything works fine.
I am using Django 2.2 with virtualenv, here is my list
Python==3.7.2
Django 2.2
Virtualenv==16.5.0
Django==2.2
django-widget-tweaks==1.4.3
djangorestframework==3.9.2
Pillow==6.0.0
Pygments==2.3.1
pytz==2018.7
sqlparse==0.3.0
Settings.py
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
<…>
latest crash with pytz==2019.1 update
(env2) D:\coding\Webprojects\phone>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
Traceback (most recent call last):
File "manage.py", line 21, in <module>
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
utility.execute()
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\commands\runserver.py", line 60, in execute
super().execute(*args, **options)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\base.py", line 364, in execute
output = self.handle(*args, **options)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\commands\runserver.py", line 95, in handle
self.run(**options)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\commands\runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "D:\coding\virtual_env\env2\lib\site-packages\django\utils\autoreload.py", line 579, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "D:\coding\virtual_env\env2\lib\site-packages\django\utils\autoreload.py", line 564, in start_django
reloader.run(django_main_thread)
File "D:\coding\virtual_env\env2\lib\site-packages\django\utils\autoreload.py", line 272, in run
get_resolver().urlconf_module
File "D:\coding\virtual_env\env2\lib\site-packages\django\utils\functional.py", line 80, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "D:\coding\virtual_env\env2\lib\site-packages\django\urls\resolvers.py", line 564, in urlconf_module
return import_module(self.urlconf_name)
File "D:\coding\virtual_env\env2\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
Exception in thread Thread-1:
Traceback (most recent call last):
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\utils.py", line 66, in __getitem__
return self._engines[alias]
KeyError: 'django'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "d:\coding\appz\python 3_7_2_64bit\Lib\threading.py", line 917, in _bootstrap_inner
self.run()
File "d:\coding\appz\python 3_7_2_64bit\Lib\threading.py", line 865, in run
self._target(*self._args, **self._kwargs)
File "D:\coding\virtual_env\env2\lib\site-packages\django\utils\autoreload.py", line 54, in wrapper
fn(*args, **kwargs)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
self.check(display_num_errors=True)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\base.py", line 390, in check
include_deployment_checks=include_deployment_checks,
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\management\base.py", line 377, in _run_checks
return checks.run_checks(**kwargs)
File "D:\coding\virtual_env\env2\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
new_errors = check(app_configs=app_configs)
File "D:\coding\virtual_env\env2\lib\site-packages\django\contrib\admin\checks.py", line 80, in check_dependencies
for engine in engines.all():
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\utils.py", line 90, in all
return [self[alias] for alias in self]
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\utils.py", line 90, in <listcomp>
return [self[alias] for alias in self]
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\utils.py", line 81, in __getitem__
engine = engine_cls(params)
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\backends\django.py", line 25, in __init__
options['libraries'] = self.get_templatetag_libraries(libraries)
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\backends\django.py", line 43, in get_templatetag_libraries
libraries = get_installed_libraries()
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\backends\django.py", line 108, in get_installed_libraries
for name in get_package_libraries(pkg):
File "D:\coding\virtual_env\env2\lib\site-packages\django\template\backends\django.py", line 121, in get_package_libraries
module = import_module(entry[1])
File "D:\coding\virtual_env\env2\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:\coding\virtual_env\env2\lib\site-packages\rest_framework\templatetags\rest_framework.py", line 15, in <module>
from rest_framework.renderers import HTMLFormRenderer
File "D:\coding\virtual_env\env2\lib\site-packages\rest_framework\renderers.py", line 20, in <module>
from django.test.client import encode_multipart
File "D:\coding\virtual_env\env2\lib\site-packages\django\test\client.py", line 23, in <module>
from django.test import signals
File "<frozen importlib._bootstrap>", line 980, in _find_and_load
File "<frozen importlib._bootstrap>", line 149, in __enter__
File "<frozen importlib._bootstrap>", line 94, in acquire
_frozen_importlib._DeadlockError: deadlock detected by _ModuleLock('django.test.signals') at 2019111034216
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:\coding\Webprojects\phone\phone\urls.py", line 27, in <module>
path('data/', include('dataout.urls', namespace='data_home')),
File "D:\coding\virtual_env\env2\lib\site-packages\django\urls\conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "D:\coding\virtual_env\env2\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:\coding\Webprojects\phone\dataout\urls.py", line 2, in <module>
from rest_framework.urlpatterns import format_suffix_patterns
File "D:\coding\virtual_env\env2\lib\site-packages\rest_framework\urlpatterns.py", line 8, in <module>
from rest_framework.settings import api_settings
File "D:\coding\virtual_env\env2\lib\site-packages\rest_framework\settings.py", line 26, in <module>
from django.test.signals import setting_changed
File "D:\coding\virtual_env\env2\lib\site-packages\django\test\__init__.py", line 3, in <module>
from django.test.client import Client, RequestFactory
ImportError: cannot import name 'Client' from 'django.test.client' (D:\coding\virtual_env\env2\lib\site-packages\django\test\client.py)

ImportError: cannot import name 'URLPattern'

I am using django 1.11 and django rest version 3.
and i used drf-nested routers . for makin path like /abc/{id}/xyz/where abc and xyz are two views from AbcViewSet and XyzViewSet.
urls.py
from rest_framework_nested import routers
router = routers.SimpleRouter()
router.register(r'abc',AbcViewset)
abc_router = routers.NestedSimpleRouter(router,r'abc', lookup='abc')
abc_router.register(r'xyz', XyzViewset, base_name='abc-xyz')
urlpatterns = [
url(r'', include(router.urls)),
]
And I got the following traceback. I dont know what is happening with the code and what the error exactly is?
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x7fb79f505a60>
Traceback (most recent call last):
File "/home/johan/.local/lib/python3.6/site-packages/django/utils/autoreload.py", line 227, in wrapper
fn(*args, **kwargs)
File "/home/johan/.local/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
self.check(display_num_errors=True)
File "/home//.local/lib/python3.6/site-packages/django/core/management/base.py", line 359, in check
include_deployment_checks=include_deployment_checks,
File "/home/johan/.local/lib/python3.6/site-packages/django/core/management/base.py", line 346, in _run_checks
return checks.run_checks(**kwargs)
File "/home/johan/.local/lib/python3.6/site-packages/django/core/checks/registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/johan/.local/lib/python3.6/site-packages/django/core/checks/urls.py", line 16, in check_url_config
return check_resolver(resolver)
File "/home/johan/.local/lib/python3.6/site-packages/django/core/checks/urls.py", line 26, in check_resolver
return check_method()
File "/home/johan/.local/lib/python3.6/site-packages/django/urls/resolvers.py", line 254, in check
for pattern in self.url_patterns:
File "/home/johan/.local/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/johan/.local/lib/python3.6/site-packages/django/urls/resolvers.py", line 405, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/johan/.local/lib/python3.6/site-packages/django/utils/functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/johan/.local/lib/python3.6/site-packages/django/urls/resolvers.py", line 398, in urlconf_module
return import_module(self.urlconf_name)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/johan/Documents/Abc/backend/abc/urls.py", line 24, in <module>
from rest_framework.documentation import include_docs_urls
File "/home/johan/.local/lib/python3.6/site-packages/rest_framework/documentation.py", line 6, in <module>
from rest_framework.schemas import SchemaGenerator, get_schema_view
File "/home/johan/.local/lib/python3.6/site-packages/rest_framework/schemas/__init__.py", line 25, in <module>
from .generators import SchemaGenerator
File "/home/johan/.local/lib/python3.6/site-packages/rest_framework/schemas/generators.py", line 18, in <module>
from rest_framework.compat import (
ImportError: cannot import name 'URLPattern'
How can this error be resolved?

Unable to import view from different app

I'm trying to import a view from one app into another app but it's giving me this error:
Traceback (most recent call last):
File "manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/home/trie/Desktop/django/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 371, in execute_from_command_line
utility.execute()
File "/home/trie/Desktop/django/venv/lib/python3.5/site-packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/trie/Desktop/django/venv/lib/python3.5/site-packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/trie/Desktop/django/venv/lib/python3.5/site-packages/django/core/management/base.py", line 332, in execute
self.check()
File "/home/trie/Desktop/django/venv/lib/python3.5/site-packages/django/core/management/base.py", line 364, in check
include_deployment_checks=include_deployment_checks,
File "/home/trie/Desktop/django/venv/lib/python3.5/site-packages/django/core/management/base.py", line 351, in _run_checks
return checks.run_checks(**kwargs)
File "/home/trie/Desktop/django/venv/lib/python3.5/site-packages/django/core/checks/registry.py", line 73, in run_checks
new_errors = check(app_configs=app_configs)
File "/home/trie/Desktop/django/venv/lib/python3.5/site-packages/django/core/checks/urls.py", line 13, in check_url_config
return check_resolver(resolver)
File "/home/trie/Desktop/django/venv/lib/python3.5/site-packages/django/core/checks/urls.py", line 23, in check_resolver
return check_method()
File "/home/trie/Desktop/django/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 397, in check
for pattern in self.url_patterns:
File "/home/trie/Desktop/django/venv/lib/python3.5/site-packages/django/utils/functional.py", line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/trie/Desktop/django/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 536, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/home/trie/Desktop/django/venv/lib/python3.5/site-packages/django/utils/functional.py", line 36, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/home/trie/Desktop/django/venv/lib/python3.5/site-packages/django/urls/resolvers.py", line 529, in urlconf_module
return import_module(self.urlconf_name)
File "/home/trie/Desktop/django/venv/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 673, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/trie/Desktop/django/myproject/myproject/urls.py", line 20, in <module>
path('home/',include('wapperapp.urls')),
File "/home/trie/Desktop/django/venv/lib/python3.5/site-packages/django/urls/conf.py", line 34, in include
urlconf_module = import_module(urlconf_module)
File "/home/trie/Desktop/django/venv/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 673, in exec_module
File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
File "/home/trie/Desktop/django/myproject/wapperapp/urls.py", line 3, in <module>
from . import views
File "/home/trie/Desktop/django/myproject/wapperapp/views.py", line 2, in <module>
from myproject.vidbrowser.views import index
ImportError: No module named 'myproject.vidbrowser'
I've imports like this in other parts of the project which isn't giving any error but this one does...
I am sure the thing I'm trying to import exists but I can't seem to find out why it's not working.
Does anyone know what the problem is here?
The outer myproject directory (that contains manage.py) is on the Python path. Therefore the import should be:
from vidbrowser.views import index
Try this
from appname import views
and then
views.index
or
from appname.views import index