django-admin打开一个新项目

kt06eoxx  于 2023-07-01  发布在  Go
关注(0)|答案(2)|浏览(100)

我使用这个命令:
django-admin startproject Hello
启动一个新项目,但我得到以下错误

django-admin : The term 'django-admin' is not recognized as the name 
of a cmdlet, function, script file, or operable program. Check the   
spelling of the name, or if a path was included, verify that the     
path is correct and try again.
At line:1 char:1
+ django-admin startproject Hello
+ ~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (django-admin:String)  
   [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

我刚开始使用Django,这太令人沮丧了

swvgeqrz

swvgeqrz1#

看来你没有安装Django。如果你已经安装了它,你应该检查一下你的虚拟环境(venv)是否激活了。查看此文档:https://docs.python.org/pt-br/3/library/venv.html
转到项目目录并尝试以下操作:

python3 -m venv venv
source venv/bin/activate

然后:

django-admin --version **(to check if it is installed)**
django-admin startproject Hello
1tuwyuhd

1tuwyuhd2#

创建虚拟环境后,尝试在vscode中安装django

(venv) c:\mycode\hello> $ pip install django

then:检查django的版本

(venv) c:\mycode\hello> $ django --version
(venv) c:\mycode\hello> $ django-admin startproject <projectname>

相关问题