Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python manage.py runserver无效语法_Python_Django_Python 3.x - Fatal编程技术网

Python manage.py runserver无效语法

Python manage.py runserver无效语法,python,django,python-3.x,Python,Django,Python 3.x,更新 我无意中编辑了manage.py文件 manage.py文件中的代码需要为- #!/usr/bin/env python """Django's command-line utility for administrative tasks.""" import os import sys def main(): os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_project1.settings') try:

更新

我无意中编辑了manage.py文件

manage.py文件中的代码需要为-

#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys


def main():
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_project1.settings')
    try:
        from django.core.management import execute_from_command_line
    except ImportError as exc:
        raise ImportError(
            "Couldn't import Django. Are you sure it's installed and "
            "available on your PYTHONPATH environment variable? Did you "
            "forget to activate a virtual environment?"
        ) from exc
    execute_from_command_line(sys.argv)


if __name__ == '__main__':
    main()
然后在CMD(Windows键+R)中,我将-

原始问题 我正在尝试运行命令
python manage.py runserver
$python manage.py runserver
$python manage.py runserver
,但不断出现错误

我试过
python manage.py运行服务器
manage.py运行服务器
python3 manage.py运行服务器

Microsoft Windows [Version 10.0.17134.165]
(c) 2018 Microsoft Corporation. All rights reserved.

C:\Users\HP>cd C:\Users\HP

C:\Users\HP>cd C:Users\HP\django_project
The system cannot find the path specified.

C:\Users\HP>cd C:\Users\HP\django_project

C:\Users\HP\django_project>python manage.py runserver
  File "manage.py", line 3
    python3 manage.py runserver
                 ^
SyntaxError: invalid syntax

C:\Users\HP\django_project>manage.py runserver
  File "C:\Users\HP\django_project\manage.py", line 3
    python3 manage.py runserver
                 ^
SyntaxError: invalid syntax

C:\Users\HP\django_project>python3 manage.py runserver
'python3' is not recognized as an internal or external command,
operable program or batch file.

C:\Users\HP\django_project>python manage.py runserver
  File "manage.py", line 3
    python3 manage.py runserver
                 ^
SyntaxError: invalid syntax


C:\Users\HP\django_project>dir /s >listmyfolder.txt



 Volume in drive C is Windows
 Volume Serial Number is D84A-5EE6

 Directory of C:\Users\HP\django_project

10/20/2019  10:15 PM    <DIR>          .
10/20/2019  10:15 PM    <DIR>          ..
10/19/2019  05:50 PM    <DIR>          django_project
10/20/2019  10:15 PM               113 listmyfolder.txt
10/20/2019  08:23 PM                53 manage.py
               2 File(s)            166 bytes
Microsoft Windows[版本10.0.17134.165]
(c) 2018年微软公司。版权所有。
C:\Users\HP>cd C:\Users\HP
C:\Users\HP>cd C:Users\HP\django\u项目
系统找不到指定的路径。
C:\Users\HP>cd C:\Users\HP\django\u项目
C:\Users\HP\django\u project>python manage.py运行服务器
文件“manage.py”,第3行
python3 manage.py运行服务器
^
SyntaxError:无效语法
C:\Users\HP\django\u项目>manage.py运行服务器
文件“C:\Users\HP\django\u project\manage.py”,第3行
python3 manage.py运行服务器
^
SyntaxError:无效语法
C:\Users\HP\django_project>python3 manage.py运行服务器
“python3”未被识别为内部或外部命令,
可操作的程序或批处理文件。
C:\Users\HP\django\u project>python manage.py运行服务器
文件“manage.py”,第3行
python3 manage.py运行服务器
^
SyntaxError:无效语法
C:\Users\HP\django_project>dir/s>listmyfolder.txt
驱动器C中的卷是Windows
卷序列号为D84A-5EE6
C:\Users\HP\django\u项目目录
2019年10月20日晚上10:15。
2019年10月20日晚上10:15。。
2019年10月19日下午5:50 django_项目
2019年10月20日晚上10:15 113 listmyfolder.txt
2019年10月20日08:23 PM 53.py
2个文件166字节
以下是django_项目的内容-

 Directory of C:\Users\HP\django_project\django_project

10/19/2019  05:50 PM    <DIR>          .
10/19/2019  05:50 PM    <DIR>          ..
10/19/2019  05:50 PM             3,232 settings.py
10/19/2019  05:50 PM               777 urls.py
10/19/2019  05:50 PM               421 wsgi.py
10/19/2019  05:50 PM                 0 __init__.py
               4 File(s)          4,430 bytes

     Total Files Listed:
               6 File(s)          4,596 bytes
               5 Dir(s)   7,345,328,128 bytes free
C:\Users\HP\django\u项目\django\u项目目录 2019年10月19日下午5:50。 2019年10月19日下午5:50。。 2019年10月19日下午5:50 3232.py 2019年10月19日下午5:50 777 URL.py 2019年10月19日下午5:50 421 wsgi.py 2019年10月19日下午5:50开始 4个文件4430字节 列出的文件总数: 6个文件4596字节 5个目录7345328128字节可用
出于某种原因,您似乎编辑了manage.py文件,使其包含文本“python3 manage.py runserver”。我不知道你为什么这么做,但你应该删除它。

谢谢你,我对Sublime没有经验,所以我无意中做出了改变。
 Directory of C:\Users\HP\django_project\django_project

10/19/2019  05:50 PM    <DIR>          .
10/19/2019  05:50 PM    <DIR>          ..
10/19/2019  05:50 PM             3,232 settings.py
10/19/2019  05:50 PM               777 urls.py
10/19/2019  05:50 PM               421 wsgi.py
10/19/2019  05:50 PM                 0 __init__.py
               4 File(s)          4,430 bytes

     Total Files Listed:
               6 File(s)          4,596 bytes
               5 Dir(s)   7,345,328,128 bytes free