简体   繁体   English

执行“Python manage.py runserver”时出现Django Runserver错误

[英]Django Runserver error while executing "Python manage.py runserver"

C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\Scripts\FirstDjango
Proj>python manage.py runserver
Exception ignored in thread started by: <function check_errors.<locals>.wrapper
at 0x00000000038D00D0>
Traceback (most recent call last):
  File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\utils\autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\core\management\commands\runserver.py", line 117, in inner_run
    autoreload.raise_last_exception()
  File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\utils\autoreload.py", line 251, in raise_last_exception
    six.reraise(*_exception)
  File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\utils\six.py", line 685, in reraise
    raise value.with_traceback(tb)
  File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\utils\autoreload.py", line 228, in wrapper
    fn(*args, **kwargs)
  File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\apps\registry.py", line 85, in populate
    app_config = AppConfig.create(entry)
  File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\apps\config.py", line 94, in create
    module = import_module(entry)
  File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\importl
ib\__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\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\contrib\admin\__init__.py", line 4, in <module>
    from django.contrib.admin.filters import (
  File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\contrib\admin\filters.py", line 10, in <module>
    from django.contrib.admin.options import IncorrectLookupParameters
  File "C:\Users\SRIRAM_CHIVO\AppData\Local\Programs\Python\Python38\lib\site-pa
ckages\django\contrib\admin\options.py", line 12, in <module>
    from django.contrib.admin import helpers, widgets
SyntaxError: Generator expression must be parenthesized (widgets.py, line 152)

Django version installed successfully-1.11.10 python version-3.8.1 Django版本安装成功-1.11.10 python version-3.8.1

Project created and manage.py as well created.项目已创建,manage.py 也已创建。

BUt while i am trying runserver,Throwing an error with this this big passage: Help me out how can i solve this?但是当我尝试运行服务器时,在这个大段落中抛出一个错误:帮我解决这个问题?

The same happened with me also, but this issue is a minor one as it happens if you have multiple versions of Python on your system, you can select a specific Python version by running python3 or whichever version you want.我也发生了同样的情况,但这个问题是一个小问题,因为如果您的系统上有多个 Python 版本,您可以通过运行python3或您想要的任何版本来选择特定的 Python 版本。 So you should start from the beginning, uninstall Django first, then create a virtual environment, decide upon a directory where you want to place it, and run the venv module as a script with the directory path:所以你应该从头开始,先卸载 Django,然后创建一个虚拟环境,决定你想要放置它的目录,然后使用目录路径将venv模块作为脚本运行:

python3 -m venv tutorial-env

This will create the tutorial-env directory if it doesn't exist, and also create directories inside it Once you've created a virtual environment, you may activate it.如果它不存在,这将创建 tutorial-env 目录,并在其中创建目录。创建虚拟环境后,您可以激活它。

On Windows, run:在 Windows 上,运行:

tutorial-env\Scripts\activate.bat

On Unix or MacOS, run:在 Unix 或 MacOS 上,运行:

source tutorial-env/bin/activate

Now, In the command prompt, ensure your virtual environment is active, and execute the following command:现在,在命令提示符中,确保您的虚拟环境处于活动状态,并执行以下命令:

py -m pip install Django

NOTE: If django-admin only displays the help text no matter what arguments it is given, there is probably a problem with the file association in Windows.注意:如果django-admin无论给出什么参数都只显示帮助文本,则 Windows 中的文件关联可能有问题。 Check if there is more than one environment variable set for running Python scripts in PATH .检查是否在PATH设置了多个用于运行 Python 脚本的环境变量。 This usually occurs when there is more than one Python version installed.这通常发生在安装了多个 Python 版本时。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM