python:无法打开文件“ django-admin.py”:[Errno 2]没有这样的文件或目录 [英] python: can't open file 'django-admin.py': [Errno 2] No such file or directory

查看:181
本文介绍了python:无法打开文件“ django-admin.py”:[Errno 2]没有这样的文件或目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一台Mac,并且开始在Django上工作。当我尝试通过在终端上编写

I have a mac and I am starting to work on django. When I try to make a project on the terminal by writing

python django-admin.py startproject myproject

我收到此错误

python: can't open file 'django-admin.py': [Errno 2] No such file or directory

当我四处寻找帮助时,一种解决方案建议写django-admin.py类型来获取django-admin.py的位置并使用它。

While I was looking around for help, one solution suggested to write type django-admin.py to get the location of django-admin.py and use that.

所以当我输入

python /usr/local/bin/django-admin.py startproject myproject

我的项目已创建。

有人可以告诉我我为什么需要这样做,为什么我不能只写django-admin.py?

Can anyone tell my why I need to do this and why I can't write just django-admin.py? Also is there anyway to get around this?

推荐答案

您正在混淆两种引用可执行文件的方式。

You're confusing two ways of referring to an executable file.

/ usr / local / bin 在您的路径中,而 django-admin.py 被标记为可执行文件,因此您可以在没有初始 python 的情况下引用它:

/usr/local/bin is in your path, and django-admin.py is marked as executable, so you can refer to it without the initial python:

django-admin.py startproject myproject

从<$开始时c $ c> python ,即在此路径下使用脚本启动Python。因此,如果您要启动的脚本不在当前目录中,则需要传递完整路径。

When you start with python, that is saying "start Python with the script at this path". So, you need to pass the full path, if the script you're trying to start isn't in your current directory.

这篇关于python:无法打开文件“ django-admin.py”:[Errno 2]没有这样的文件或目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆