django runserver 命令出错

时间:2021-01-22 12:36:18

标签: django django-models django-views django-templates

操作系统:Windows 10

现在,对于运行服务器命令的项目,我得到了这个:
这是我的项目结构。我已经安装了这个项目的所有要求,但仍然出现这个错误。我发现运行服务器命令存在错误,但没有一个令人满意。如果这是重复的,我很抱歉,但我很确定它不是。如果需要其他文件和代码片段,我会将所有内容放在这里。非常感谢。

 D:.
    |   main.py
    |
    |   README.md
    |   
    +---BLL
    |   |   asgi.py
    |   |   requirements.txt
    |   |   settings.py
    |   |   urls.py
    |   |   wsgi.py
    |   |   __init__.py
    |   |   
    |   \---__pycache__
    |           settings.cpython-37.pyc
    |           settings.cpython-39.pyc
    |           urls.cpython-37.pyc
    |           urls.cpython-39.pyc
    |           __init__.cpython-37.pyc
    |           __init__.cpython-39.pyc
    |           
    +---DAL
    |   |   db.sqlite3
    |   |   __init__.py
    |   |   
    |   +---account
    |   |   |   admin.py
    |   |   |   apps.py
    |   |   |   forms.py
    |   |   |   models.py
    |   |   |   tests.py
    |   |   |   views.py
    |   |   |   __init__.py
    |   |   |   
    |   |   +---migrations
    |   |   |   |   0001_initial.py
    |   |   |   |   __init__.py
    |   |   |   |   
    |   |   |   \---__pycache__
    |   |   |           0001_initial.cpython-38.pyc
    |   |   |           __init__.cpython-38.pyc
    |   |   |           
    |   |   \---__pycache__
    |   |           admin.cpython-37.pyc
    |   |           admin.cpython-38.pyc
    |   |           admin.cpython-39.pyc
    |   |           apps.cpython-37.pyc
    |   |           apps.cpython-38.pyc
    |   |           apps.cpython-39.pyc
    |   |           forms.cpython-38.pyc
    |   |           models.cpython-37.pyc
    |   |           models.cpython-38.pyc
    |   |           models.cpython-39.pyc
    |   |           views.cpython-38.pyc
    |   |           __init__.cpython-37.pyc
    |   |           __init__.cpython-38.pyc
    |   |           __init__.cpython-39.pyc
    |   |           
    |   \---chatbot
    |       |   admin.py
    |       |   apps.py
    |       |   data.pickle
    |       |   loadAI.py
    |       |   models.py
    |       |   session.json
    |       |   tests.py
    |       |   trainAI.py
    |       |   views.py
    |       |   __init__.py
    |       |   
    |       +---migrations
    |       |       0001_initial.py
    |       |       __init__.py
    |       |       
    |       +---model
    |       |       testmodel.h5
    |       |       
    |       \---__pycache__
    |               admin.cpython-37.pyc
    |               admin.cpython-39.pyc
    |               apps.cpython-37.pyc
    |               apps.cpython-39.pyc
    |               models.cpython-37.pyc
    |               models.cpython-39.pyc
    |               trainAI.cpython-37.pyc
    |               trainAI.cpython-39.pyc
    |               views.cpython-37.pyc
    |               views.cpython-39.pyc
    |               __init__.cpython-37.pyc
    |               __init__.cpython-39.pyc
    |               
    +---TESTS
    |       test.py
    |       
    \---UI
        |   admin.py
        |   apps.py
        |   models.py
        |   tests.py
        |   urls.py
        |   views.py
        |   __init__.py
        |   
        +---images
        |       1.PNG
        |       10.PNG
        |       2.PNG
        |       3.PNG
        |       4.PNG
        |       5.PNG
        |       6.PNG
        |       7.PNG
        |       8.PNG
        |       9.PNG
        |       chatbot.GIF
        |       
        +---static
        |   \---UI
        |       +---audio
        |       |       audio0.mp3
        |       |       audio1.mp3
        |       |       audio2.mp3
        |       |       audio3.mp3
        |       |       
        |       +---css
        |       |       css-main.css
        |       |       css-responsive.css
        |       |       
        |       \---images
        |               bg.jpg
        |               landscape1.jpg
        |               logo.ico
        |               logo.jpg
        |               user.png
        |               
        +---templates
        |   \---UI
        |       |   base.html
        |       |   index.html
        |       |   
        |       +---errors
        |       |       404.html
        |       |       500.html
        |       |       
        |       \---pages
        |               about.html
        |               account.html
        |               changepass-done.html
        |               changepass.html
        |               chatbot.html
        |               FAQs.html
        |               login.html
        |               signup.html
        |               update.html
        |               
        \---__pycache__
                admin.cpython-37.pyc
                admin.cpython-39.pyc
                apps.cpython-37.pyc
                apps.cpython-39.pyc
                models.cpython-37.pyc
                models.cpython-39.pyc
                urls.cpython-37.pyc
                urls.cpython-39.pyc
                views.cpython-37.pyc
                views.cpython-39.pyc
                __init__.cpython-37.pyc
                __init__.cpython-39.pyc

当我使用 python main.py runserver 命令时,我从 git hub 克隆了这个项目,它给了我这个错误:

D:\Covid19Chatbot-master>python main.py runserver
        Watching for file changes with StatReloader
        Performing system checks...
        
        2021-01-22 17:20:47.257952: W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'cudart64_101.dll'; dlerror: cudart64_101.dll not found
        2021-01-22 17:20:47.263540: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
        [nltk_data] Downloading package punkt to
        [nltk_data]     C:\Users\mehra\AppData\Roaming\nltk_data...
        [nltk_data]   Package punkt is already up-to-date!
        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 "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\autoreload.py", line 53, in wrapper
            fn(*args, **kwargs)
          File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\commands\runserver.py", line 117, in inner_run
            self.check(display_num_errors=True)
          File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\base.py", line 395, in check
            include_deployment_checks=include_deployment_checks,
          File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\management\base.py", line 382, in _run_checks
            return checks.run_checks(**kwargs)
          File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\checks\registry.py", line 72, in run_checks
            new_errors = check(app_configs=app_configs)
          File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 13, in check_url_config
            return check_resolver(resolver)
          File "C:\ProgramData\Anaconda3\lib\site-packages\django\core\checks\urls.py", line 23, in check_resolver
            return check_method()
          File "C:\ProgramData\Anaconda3\lib\site-packages\django\urls\resolvers.py", line 407, in check
            for pattern in self.url_patterns:
          File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\functional.py", line 48, in __get__
            res = instance.__dict__[self.name] = self.func(instance)
          File "C:\ProgramData\Anaconda3\lib\site-packages\django\urls\resolvers.py", line 588, in url_patterns
            patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
          File "C:\ProgramData\Anaconda3\lib\site-packages\django\utils\functional.py", line 48, in __get__
            res = instance.__dict__[self.name] = self.func(instance)
          File "C:\ProgramData\Anaconda3\lib\site-packages\django\urls\resolvers.py", line 581, in urlconf_module
            return import_module(self.urlconf_name)
          File "C:\ProgramData\Anaconda3\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:\Covid19Chatbot-master\BLL\urls.py", line 21, in <module>
            path('', include('UI.urls')),
          File "C:\ProgramData\Anaconda3\lib\site-packages\django\urls\conf.py", line 34, in include
            urlconf_module = import_module(urlconf_module)
          File "C:\ProgramData\Anaconda3\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:\Covid19Chatbot-master\UI\urls.py", line 4, in <module>
            from chatbot.views import (
          File "D:\Covid19Chatbot-master\DAL\chatbot\views.py", line 6, in <module>
            ai = TrainAI()
          File "D:\Covid19Chatbot-master\DAL\chatbot\trainAI.py", line 24, in __init__
            jsonContent = json.loads(res.content.decode())
          File "C:\ProgramData\Anaconda3\lib\json\__init__.py", line 348, in loads
            return _default_decoder.decode(s)
          File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 337, in decode
            obj, end = self.raw_decode(s, idx=_w(s, 0).end())
          File "C:\ProgramData\Anaconda3\lib\json\decoder.py", line 355, in raw_decode
            raise JSONDecodeError("Expecting value", s, err.value) from None
        json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

1 个答案:

答案 0 :(得分:0)

错误来自 trainAI 的第 22-24 行

    website = r"https://coronavirus-ph-api.herokuapp.com/total/"
    res = requests.get(website)
    jsonContent = json.loads(res.content.decode())

这个网站没有内容,也没有返回json,这就是为什么它不能遍历它并抛出错误