命令未发现:django-admin.py

时间:2021-02-23 19:20:37

I am a complete beginner to Python/Django, but I want to dive right in and start experimenting. Thus I was following this guide on installing Python/Django http://devcenter.heroku.com/articles/django.

我完全是Python/Django的初学者,但是我想深入研究并开始实验。因此,我遵循了关于安装Python/Django的指南http://devcenter.heroku.com/articles/django。

Everything is working fine until the step

直到迈出第一步,一切都很顺利

django-admin.py startproject hellodjango

django-admin。py startproject hellodjango

Where I get

在那里我得到

command not found: django-admin.py

命令未发现:django-admin.py

Now I have tried a few things, but none have really worked out. Is there someone kind enough to point me in the right direction?

现在我已经尝试了一些东西,但没有一个真正成功。有什么人能给我指明正确的方向吗?

P.S. Is there a great guide out there on running Python/Django locally on a Mac to run and test apps?

另外,在Mac上运行Python/Django来运行和测试应用程序,有什么好的指南吗?

I'm on Mac OS X Lion, Python 2.7.

我用的是Mac OS X Lion, Python 2。7。

13 个解决方案

#1


21  

Actually, if you use Ubuntu, it's just django-admin not django-admin.py.

实际上,如果你使用Ubuntu,它就是django-admin而不是django-admin.py。

Resides in /usr/bin
Probably the same thing on Mac.
You're using a Windows tutorial.

位于/usr/bin中,这可能与Mac上的相同。

It may also tell you

它也可能告诉你

python manage.py runserver

and that is actually

这实际上是

python ./manage.py runserver

#2


6  

Make sure you properly did the source bin/activate command. If you skip that, or do it in a different terminal window, or close the window then re-open it, you won't be in the virtualenv and you won't have access to the django-admin.py command in your environment.

确保您正确地执行了源文件/激活命令。如果您跳过这个操作,或者在另一个终端窗口中执行,或者关闭窗口然后重新打开它,那么您将不在virtualenv中,您将无法访问django-admin。您的环境中的py命令。

#3


3  

As Timmy said above, it could just be that django-admin.py is not on your system path. See here - https://code.djangoproject.com/wiki/InstallationPitfalls - for 3 possible causes with solutions.

就像Timmy上面说的,可能就是django-admin。py不在系统路径上。查看这里- https://code.djangoproject.com/wiki/installation陷阱-针对3个可能的原因和解决方案。

#4


2  

To solve this problem, you need:

要解决这个问题,您需要:

  1. Find the main folder of Django, and find the django-admin.py file

    找到Django的主文件夹,并找到Django -admin。py文件

    Typically, the file is in <YOUR_DJANGO_FOLDER>/bin/django-admin.py

    通常,文件在 /bin/django-admin.py中

  2. Create a link for this file

    为这个文件创建一个链接

    ln -s /bin/django-admin.py /usr/local/bin/django-admin

    ln - s /bin/django-admin。py /usr/local/bin/django-admin

  3. Type django-admin in your command to check if it works

    在命令中输入django-admin以检查它是否正常工作

#5


2  

To Windows users

Windows用户

using django-admin instead of django-admin.py worked for me in Windows.

使用django-admin代替django-admin。py在Windows里为我工作。

命令未发现:django-admin.py

#6


1  

To windows users out there: I have faced this problem several times and here are the checkpoints:

对于windows用户:我曾多次遇到过这个问题,以下是检查点:

When there is problem initiating a new project, make sure:

当新项目启动出现问题时,请确保:

1) python is working in the command line (type in python and see if you get the console)

1) python在命令行中工作(在python中输入并查看是否获得控制台)

2) specify the full path of django-admin.py in the command

2)指定django-admin的完整路径。py在命令

3) check django-admin.py is in the system path

3)检查django-admin。py在系统路径中

4) cd the command line path to where you want the new project

4) cd命令行路径到您想要新项目的位置

Screenshot of what finally worked for me (only the last command): https://flic.kr/p/r9LJ67 (* doesn't allow me to post pictures yet)

最后为我工作的屏幕截图(只有最后一个命令):https://flic.kr/p/r9LJ67 (*不允许我上传图片)

#7


0  

I have used follwong command to install (/usr/local/bin) MAC OS

我使用了follwong命令来安装(/usr/local/bin) MAC OS

pip install django

django-admin startproject mysite

#8


0  

If you come across command not found: django-admin.py problem which means you don't installed django frame work. You should install the framework using pip.

如果遇到未找到的命令:django-admin。py问题,这意味着您没有安装django框架工作。您应该使用pip安装框架。

pip install django

After that look at the directory if the related script exist or not.
Look into C:\Python27\Scriptsfolder to check for django-admin.py exist or not.

在此之后,查看相关脚本是否存在的目录。查看C:\Python27\Scriptsfolder以检查django-admin。py或不存在。

#9


0  

The following guide in official site https://code.djangoproject.com/wiki/InstallationPitfalls

以下是官方网站https://code.djangoproject.com/wiki/installation中的指南

First, you should find location of django-admin.py by

首先,您应该找到django-admin的位置。py由

which django-admin.py

Example: in my case

例如:在我的例子中

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/bin/django-admin.py

/图书馆/框架/ Python.framework /版本/ 2.7 / lib / python2.7 /网站/ django / bin / django-admin.py

You use sudo ln -s to relocate django-admin-py to /usr/local/bin

您使用sudo ln -s将django-admin-py迁移到/usr/local/bin

sudo ln -s /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/bin/django-admin.py /usr/local/bin/django-admin.py

after that change permission of the django-admin to be executable sudo chmod +x /usr/local/bin/django-admin.py

之后,django-admin的修改权限是可执行的sudo chmod +x /usr/local/bin/django-admin.py

Now you can use django-admin.py startproject mysite to create your django project

现在可以使用django-admin。py startproject mysite创建django项目


If you want to change django-admin.py to django-admin to look like more compact you can use sudo mv /usr/local/bin/django-admin.py /usr/local/bin/django-admin

如果你想改变管理员。py到django-admin看起来更紧凑,您可以使用sudo mv /usr/local/bin/django-admin。py /usr/local/bin/django-admin

Hope this help for you !

希望这对你有所帮助!

#10


0  

On RHEL stock python config:

关于RHEL stock python配置:

django-admin.py startproject mysite

django-admin。py startproject mysite

#11


0  

if you install django by pip

如果您通过pip安装django

  • ensure you have installed django:
  • 确保您已经安装了django:

pip list or pip freeze

pip列表或pip冻结

if there is django then

如果有django的话

  • get location of django:
  • django的位置:

pip show django

皮普显示django

if location is '/Users/xxxxx/Library/Python/2.7/lib/python/site-packages' then

如果位置是“/Users/xxxxx/Library/Python/2.7/lib/ Python/ site-packages”

  • relocate django-admin-py to /usr/local/bin:
  • 搬迁django-admin-py /usr/local/bin:

ln -s /Users/xxxxx/Library/Python/2.7/lib/python/site-packages/django/bin/django-admin.py /usr/local/bin/django-admin.py

ln - s /用户/ xxxxx /图书馆/ Python / 2.7 / lib / Python /网站/ django / bin / django-admin。py /usr/local/bin/django-admin.py

#12


0  

If you´re on Windows, here´s what worked for me (using pylauncher):

如果你´再保险在Windows上,这里´s为我工作(使用pylauncher):

$ py -m django startproject myproject

#13


0  

This simply worked for me. Install django on your virtualenv:

这对我很有效。在你的virtualenv上安装django:

pip install django

And then run:

然后运行:

django-admin startproject myprojectname

#1


21  

Actually, if you use Ubuntu, it's just django-admin not django-admin.py.

实际上,如果你使用Ubuntu,它就是django-admin而不是django-admin.py。

Resides in /usr/bin
Probably the same thing on Mac.
You're using a Windows tutorial.

位于/usr/bin中,这可能与Mac上的相同。

It may also tell you

它也可能告诉你

python manage.py runserver

and that is actually

这实际上是

python ./manage.py runserver

#2


6  

Make sure you properly did the source bin/activate command. If you skip that, or do it in a different terminal window, or close the window then re-open it, you won't be in the virtualenv and you won't have access to the django-admin.py command in your environment.

确保您正确地执行了源文件/激活命令。如果您跳过这个操作,或者在另一个终端窗口中执行,或者关闭窗口然后重新打开它,那么您将不在virtualenv中,您将无法访问django-admin。您的环境中的py命令。

#3


3  

As Timmy said above, it could just be that django-admin.py is not on your system path. See here - https://code.djangoproject.com/wiki/InstallationPitfalls - for 3 possible causes with solutions.

就像Timmy上面说的,可能就是django-admin。py不在系统路径上。查看这里- https://code.djangoproject.com/wiki/installation陷阱-针对3个可能的原因和解决方案。

#4


2  

To solve this problem, you need:

要解决这个问题,您需要:

  1. Find the main folder of Django, and find the django-admin.py file

    找到Django的主文件夹,并找到Django -admin。py文件

    Typically, the file is in <YOUR_DJANGO_FOLDER>/bin/django-admin.py

    通常,文件在 /bin/django-admin.py中

  2. Create a link for this file

    为这个文件创建一个链接

    ln -s /bin/django-admin.py /usr/local/bin/django-admin

    ln - s /bin/django-admin。py /usr/local/bin/django-admin

  3. Type django-admin in your command to check if it works

    在命令中输入django-admin以检查它是否正常工作

#5


2  

To Windows users

Windows用户

using django-admin instead of django-admin.py worked for me in Windows.

使用django-admin代替django-admin。py在Windows里为我工作。

命令未发现:django-admin.py

#6


1  

To windows users out there: I have faced this problem several times and here are the checkpoints:

对于windows用户:我曾多次遇到过这个问题,以下是检查点:

When there is problem initiating a new project, make sure:

当新项目启动出现问题时,请确保:

1) python is working in the command line (type in python and see if you get the console)

1) python在命令行中工作(在python中输入并查看是否获得控制台)

2) specify the full path of django-admin.py in the command

2)指定django-admin的完整路径。py在命令

3) check django-admin.py is in the system path

3)检查django-admin。py在系统路径中

4) cd the command line path to where you want the new project

4) cd命令行路径到您想要新项目的位置

Screenshot of what finally worked for me (only the last command): https://flic.kr/p/r9LJ67 (* doesn't allow me to post pictures yet)

最后为我工作的屏幕截图(只有最后一个命令):https://flic.kr/p/r9LJ67 (*不允许我上传图片)

#7


0  

I have used follwong command to install (/usr/local/bin) MAC OS

我使用了follwong命令来安装(/usr/local/bin) MAC OS

pip install django

django-admin startproject mysite

#8


0  

If you come across command not found: django-admin.py problem which means you don't installed django frame work. You should install the framework using pip.

如果遇到未找到的命令:django-admin。py问题,这意味着您没有安装django框架工作。您应该使用pip安装框架。

pip install django

After that look at the directory if the related script exist or not.
Look into C:\Python27\Scriptsfolder to check for django-admin.py exist or not.

在此之后,查看相关脚本是否存在的目录。查看C:\Python27\Scriptsfolder以检查django-admin。py或不存在。

#9


0  

The following guide in official site https://code.djangoproject.com/wiki/InstallationPitfalls

以下是官方网站https://code.djangoproject.com/wiki/installation中的指南

First, you should find location of django-admin.py by

首先,您应该找到django-admin的位置。py由

which django-admin.py

Example: in my case

例如:在我的例子中

/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/bin/django-admin.py

/图书馆/框架/ Python.framework /版本/ 2.7 / lib / python2.7 /网站/ django / bin / django-admin.py

You use sudo ln -s to relocate django-admin-py to /usr/local/bin

您使用sudo ln -s将django-admin-py迁移到/usr/local/bin

sudo ln -s /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/bin/django-admin.py /usr/local/bin/django-admin.py

after that change permission of the django-admin to be executable sudo chmod +x /usr/local/bin/django-admin.py

之后,django-admin的修改权限是可执行的sudo chmod +x /usr/local/bin/django-admin.py

Now you can use django-admin.py startproject mysite to create your django project

现在可以使用django-admin。py startproject mysite创建django项目


If you want to change django-admin.py to django-admin to look like more compact you can use sudo mv /usr/local/bin/django-admin.py /usr/local/bin/django-admin

如果你想改变管理员。py到django-admin看起来更紧凑,您可以使用sudo mv /usr/local/bin/django-admin。py /usr/local/bin/django-admin

Hope this help for you !

希望这对你有所帮助!

#10


0  

On RHEL stock python config:

关于RHEL stock python配置:

django-admin.py startproject mysite

django-admin。py startproject mysite

#11


0  

if you install django by pip

如果您通过pip安装django

  • ensure you have installed django:
  • 确保您已经安装了django:

pip list or pip freeze

pip列表或pip冻结

if there is django then

如果有django的话

  • get location of django:
  • django的位置:

pip show django

皮普显示django

if location is '/Users/xxxxx/Library/Python/2.7/lib/python/site-packages' then

如果位置是“/Users/xxxxx/Library/Python/2.7/lib/ Python/ site-packages”

  • relocate django-admin-py to /usr/local/bin:
  • 搬迁django-admin-py /usr/local/bin:

ln -s /Users/xxxxx/Library/Python/2.7/lib/python/site-packages/django/bin/django-admin.py /usr/local/bin/django-admin.py

ln - s /用户/ xxxxx /图书馆/ Python / 2.7 / lib / Python /网站/ django / bin / django-admin。py /usr/local/bin/django-admin.py

#12


0  

If you´re on Windows, here´s what worked for me (using pylauncher):

如果你´再保险在Windows上,这里´s为我工作(使用pylauncher):

$ py -m django startproject myproject

#13


0  

This simply worked for me. Install django on your virtualenv:

这对我很有效。在你的virtualenv上安装django:

pip install django

And then run:

然后运行:

django-admin startproject myprojectname