在用Django搭建网页时,__init__窗口闪退,该文件夹内其他文件也是这样。第二个文件是快速显示一段保存文字,后闪退。
使用的python版本:3.8
以下是我在cmd输入的记录(有圆点的是我输入指令的地方)
Package Version
------------------ ----------
asgiref 3.5.1
backports.zoneinfo 0.2.1
click 7.1.2
Django 4.0.4
packaging 21.2
pip 21.3.1
pygame 2.0.3
pygame-2048 1.9.4
pyparsing 2.4.7
PyQt5 5.15.4
pyqt5-plugins 5.15.4.2.2
PyQt5-Qt5 5.15.2
PyQt5-sip 12.10.1
pyqt5-tools 5.15.4.3.2
python-dotenv 0.20.0
qt5-applications 5.15.2.2.2
qt5-tools 5.15.2.1.2
setuptools 47.1.0
sip 6.4.0
sqlparse 0.4.2
toml 0.10.2
tzdata 2022.1
WARNING: You are using pip version 21.3.1; however, version 22.2.2 is available.
You should consider upgrading via the 'c:\users\administrator\appdata\local\programs\python\python38\python.exe -m pip install --upgrade pip' command.
●C:\Users\Administrator\AppData\Local\Programs\Python\Python38>python.exe -m pip install --upgrade pip
Requirement already satisfied: pip in c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages (21.3.1)
Collecting pip
Downloading pip-22.2.2-py3-none-any.whl (2.0 MB)
|████████████████████████████████| 2.0 MB 1.1 MB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 21.3.1
Uninstalling pip-21.3.1:
Successfully uninstalled pip-21.3.1
Successfully installed pip-22.C:\Users\Administrator\AppData\Local\Programs\Python\Python38>python -m django --version
4.0.4
●C:\Users\Administrator\AppData\Local\Programs\Python\Python38>mkdir django_test
●C:\Users\Administrator\AppData\Local\Programs\Python\Python38>mkdir django_test
子目录或文件 django_test 已经存在。
●C:\Users\Administrator\AppData\Local\Programs\Python\Python38>cd django_test
●C:\Users\Administrator\AppData\Local\Programs\Python\Python38\django_test>django-admin startproject MyFirstSite
●C:\Users\Administrator\AppData\Local\Programs\Python\Python38\django_test>django-admin startproject MyFirstSite
CommandError: 'C:\Users\Administrator\AppData\Local\Programs\Python\Python38\django_test\MyFirstSite' already exists
●C:\Users\Administrator\AppData\Local\Programs\Python\Python38\django_test>cd MyFirstSite
●C:\Users\Administrator\AppData\Local\Programs\Python\Python38\django_test\MyFirstSite>python manage.py runserver
'python' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
●C:\Users\Administrator\AppData\Local\Programs\Python\Python38\django_test\MyFirstSite>set PATH=%PATH%;C:\Users\Administrator\AppData\Local\Programs\Python\Python38\
●C:\Users\Administrator\AppData\Local\Programs\Python\Python38\django_test\MyFirstSite>python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).
You have 18 unapplied migration(s). Your project may not work properly until you apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
August 21, 2022 - 11:45:45
Django version 4.0.4, using settings 'MyFirstSite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
Not Found: /favicon.ico
[21/Aug/2022 11:45:59] "GET /favicon.ico HTTP/1.1" 404 2115
Not Found: /favicon.ico
[21/Aug/2022 11:46:00] "GET /favicon.ico HTTP/1.1" 404 2115
[21/Aug/2022 11:46:00] "GET / HTTP/1.1" 200 10697
[21/Aug/2022 11:46:00] "GET /static/admin/css/fonts.css HTTP/1.1" 200 42C:\Users\Administrator\AppData\Local\Programs\Python\Python38\django_test\MyFirstSite>python manage.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying admin.0003_logentry_add_action_flag_choices... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying auth.0009_alter_user_last_name_max_length... OK
Applying auth.0010_alter_group_name_max_length... OK
Applying auth.0011_update_proxy_permissions... OK
Applying auth.0012_alter_user_first_name_max_length... OK
Applying sessions.0001_initial... OK
●C:\Users\Administrator\AppData\Local\Programs\Python\Python38\django_test\MyFirstSite>cd
C:\Users\Administrator\AppData\Local\Programs\Python\Python38\django_test\MyFirstSite
C:\Users\Administrator\AppData\Local\Programs\Python\Python38\django_test\MyFirstSite>
C:\Users\Administrator\AppData\Local\Programs\Python\Python38\django_test\MyFirstSite>cd django_test
系统找不到指定的路径。
●C:\Users\Administrator\AppData\Local\Programs\Python\Python38\django_test\MyFirstSite>cd C:\Users\Administrator\AppData\Local\Programs\Python\Python38\django_test
●C:\Users\Administrator\AppData\Local\Programs\Python\Python38\django_test>django-admin startapp root
Traceback (most recent call last):
File "c:\users\administrator\appdata\local\programs\python\python38\lib\runpy.py", line 194, in _run_module_as_main
return _run_code(code, main_globals, None,
FileFile "c:\users\administrator\appdata\local\programs\python\python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38\Scripts\django-admin.exe\__main__.py", line 7, in <module>
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\django\core\management\__init__.py", line 446, in execute_from_command_line
utility.execute()
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\django\core\management\__init__.py", line 440, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\django\core\management\base.py", line 414, in run_from_argv
self.execute(*args, **cmd_options)
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\django\core\management\base.py", line 460, in execute
output = self.handle(*args, **options)
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\django\core\management\commands\startapp.py", line 14, in handle
super().handle("app", app_name, target, **options
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\django\core\management\templates.py", line 88, in handle
self.validate_name(name)
File "c:\users\administrator\appdata\local\programs\python\python38\lib\site-packages\django\core\management\templates.py", line 272, in validate_name
import_module(name)
File "c:\users\administrator\appdata\local\programs\python\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 779, in exec_module
File "<frozen importlib._bootstrap_external>", line 916, in get_code
File "<frozen importlib._bootstrap_external>", line 846, in source_to_code
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "c:\users\administrator\appdata\local\programs\python\python38\root.py", line 14
Radiobutton(root,text="单选",value=1).pack
^
SyntaxError: invalid character in identifier
在输入django-admin startapp root之前一切正常,在输入之后就出现了文章开头所提到问题
我是一名初学者,最近对Django感兴趣,由于是自学,没教学的书,百度也百度不到出现的这个问题,自己也不知道为什什么错,所以请不要嫌弃这个问题太基础,烦请指正!