Python Forum
SyntaxError: EOF while scanning triple-quoted string literal
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
SyntaxError: EOF while scanning triple-quoted string literal
#1
Hi,

My programming assignment is to create a library website from using Django in Pycharm but I was experiencing this issue and did not get much help from my teacher.

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url('books/', include('library.urls')),
]
The code above is from the urls.py main window. I am trying to link another urls.py that i created from another location to this one but it kept giving me the SyntaxError: EOF while scanning triple-quoted string literal when i try to run the codes. Any help will be appreciated :)
Reply
#2
You need to provide at the very least the stacktrace, and you should really provide enough code to reproduce the issue. As it stands, this would say admin is not defined. Ideally, you would provide the minimal instructions for reproducing the issue (likely ten or fewer lines of code here).
Reply
#3
(Feb-05-2018, 02:46 AM)micseydel Wrote: You need to provide at the very least the stacktrace, and you should really provide enough code to reproduce the issue. As it stands, this would say admin is not defined. Ideally, you would provide the minimal instructions for reproducing the issue (likely ten or fewer lines of code here).

Do you mean that I need to add more codes before the second url statement to define admin? And if so, do you mind suggesting some ways for me to work this out?
Reply
#4
No, I'm saying you haven't provided enough information for us to identify the problem, let alone provide any solution. I can't run the code you provided and get the error you describe.
Reply
#5
(Feb-05-2018, 04:45 AM)micseydel Wrote: No, I'm saying you haven't provided enough information for us to identify the problem, let alone provide any solution. I can't run the code you provided and get the error you describe.


Let me list the whole code out

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x0000000003B4A7B8>
Traceback (most recent call last):
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\urls\resolvers.py", line 538, in url_patterns
    iter(patterns)
TypeError: 'module' object is not iterable

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run
    self.check(display_num_errors=True)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\management\base.py", line 364, in check
    include_deployment_checks=include_deployment_checks,
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\management\base.py", line 351, in _run_checks
    return checks.run_checks(**kwargs)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\checks\registry.py", line 73, in run_checks
    new_errors = check(app_configs=app_configs)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\utils\functional.py", line 36, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\urls\resolvers.py", line 545, in url_patterns
    raise ImproperlyConfigured(msg.format(name=self.urlconf_name))
django.core.exceptions.ImproperlyConfigured: The included URLconf 'ProjectSubmission2.urls' does not appear to have any patterns in it. If you see valid patterns in the file then the issue is probably caused by a circular import.
Performing system checks...

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x0000000003B4A7B8>
Traceback (most recent call last):
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run
    self.check(display_num_errors=True)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\management\base.py", line 364, in check
    include_deployment_checks=include_deployment_checks,
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\management\base.py", line 351, in _run_checks
    return checks.run_checks(**kwargs)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\checks\registry.py", line 73, in run_checks
    new_errors = check(app_configs=app_configs)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\utils\functional.py", line 36, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\urls\resolvers.py", line 536, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\utils\functional.py", line 36, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\urls\resolvers.py", line 529, in urlconf_module
    return import_module(self.urlconf_name)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\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 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\ProjectSubmission2\urls.py", line 17
    
    ^
SyntaxError: EOF while scanning triple-quoted string literal
Performing system checks...

Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x0000000003B4A7B8>
Traceback (most recent call last):
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\utils\autoreload.py", line 225, in wrapper
    fn(*args, **kwargs)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\management\commands\runserver.py", line 121, in inner_run
    self.check(display_num_errors=True)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\management\base.py", line 364, in check
    include_deployment_checks=include_deployment_checks,
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\management\base.py", line 351, in _run_checks
    return checks.run_checks(**kwargs)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\checks\registry.py", line 73, in run_checks
    new_errors = check(app_configs=app_configs)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\checks\urls.py", line 40, in check_url_namespaces_unique
    all_namespaces = _load_all_namespaces(resolver)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\core\checks\urls.py", line 57, in _load_all_namespaces
    url_patterns = getattr(resolver, 'url_patterns', [])
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\utils\functional.py", line 36, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\urls\resolvers.py", line 536, in url_patterns
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\utils\functional.py", line 36, in __get__
    res = instance.__dict__[self.name] = self.func(instance)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\site-packages\django\urls\resolvers.py", line 529, in urlconf_module
    return import_module(self.urlconf_name)
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\venv\lib\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 674, in exec_module
  File "<frozen importlib._bootstrap_external>", line 781, in get_code
  File "<frozen importlib._bootstrap_external>", line 741, in source_to_code
  File "<frozen importlib._bootstrap>", line 205, in _call_with_frames_removed
  File "D:\stuff\Poly stuff\WP\ProjectSubmission2\ProjectSubmission2\urls.py", line 17
    
    ^
SyntaxError: EOF while scanning triple-quoted string literal
This is what came out after I ran the program.

urlpatterns = [
    url(r'^admin/', admin.site.urls),
    url('books/', include('library.urls')),
]
The code above also stated that I am missing closing triple quotes but the thing is I didnt use any in my coding.
Reply
#6
You provided the stracktrace, but we need the code. We can't reliably tell you what to fix in the code without the code.

One suggestion - calling your file "urls.py" might be causing problems because it appears that the library your using has its own "urls.py" (which shows up in your stacktrace). I doubt this is a problem here, but without your code, I'm trying my best to provide anything that might be useful.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Network Scanning Libraries johnmaras 4 3,553 Nov-04-2017, 01:56 PM
Last Post: wavic

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020