无法使用django-admin.py [英] Unable to use django-admin.py

查看:177
本文介绍了无法使用django-admin.py的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始Django,试图创建我的第一个项目。我知道我需要运行命令python django-admin.py startproject iFriends(iFriends是我为项目创建的文件夹)。终端正在响应 - -bash:django-admin.py:command not found。为什么不起作用?这是错误的命令吗?



我使用的是Mac OS X 10.7.3,Django 1.4和Python 2.7.2。

解决方案

我也在Mac OS 10.7.x(与Django 1.5.1)上使用Python 2.7。我认为教程已经过时了。尝试使用django-admin-2.7.py命令,而不只是django-admin.py,其他一切都一样。经过一个多小时的调查PATHS和符号链接等,这是为我工作的解决方案。



以下是我遵循的蜿蜒的道路,如果你想忍受后代:





python -cimport sys; sys.path = sys.path [1:]; import django; print(django。路径) p>


  • 我返回了以下路径,与文档非常不同:



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




  • 我开始遵循符号链接建议,但是当我尝试创建一个符号链接到/ usr / local / bin时,我无法做到这一点(主题为另一篇文章)。

  • 在查看$ PATH($ echo $ PATH )后,我想到/ opt / local / bin而不是usr / local / bin 。而且,还有一个名为 django-admin-2.7.py 的文件。可以这样,我只需要在教程中添加命令的版本号。

  • 我导航回我的代码文件夹,我将放置我的Django项目,并按照教程( https://docs.djangoproject.com/en/1.5/intro/tutorial01/)设置一个新项目。但是,我尝试 django-admin-2.7.py 而不是 django-admin.py 。它的工作!


I am new to Django and trying to create my first project. I know that I need to run the command "python django-admin.py startproject iFriends" (iFriends is the folder that I created for the project). Terminal is responding with - "-bash: django-admin.py: command not found." Why is it not working? Is this the wrong command?

I am using Mac OS X 10.7.3, Django 1.4, and Python 2.7.2.

解决方案

I'm also using Python 2.7 on Mac OS 10.7.x (with Django 1.5.1). I think the tutorial is out of date. Try using "django-admin-2.7.py" command instead of just "django-admin.py," with everything else the same. After more than an hour investigating PATHS and symlinks, etc., this is the solution that worked for me.

Here's the winding road I followed, if you would like to suffer through it for posterity:

  • I found that the Installation Pitfalls article cited earlier was helpful in that it explained in more detail the symlink solution mentioned in the troubleshooting docs (https://docs.djangoproject.com/en/1.5/faq/troubleshooting/#troubleshooting-django-admin-py).
  • However, I couldn't find the django-admin.py file in the normal places suggested.
  • Then, I found the terminal command that will tell you where the files are (also from the django docs, under how to uninstall):

python -c "import sys; sys.path = sys.path[1:]; import django; print(django.path)"

  • Mine returned the following path, very different from the documentation:

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

  • I began to follow the symlink suggestion, but then when I attempted to create a symlink to /usr/local/bin, I couldn't do it (subject for another post).
  • After looking at the $PATH ($ echo $PATH), I thought to look in /opt/local/bin instead of usr/local/bin. And lo-and-behold, there was a file called django-admin-2.7.py. Could it be that I just needed to add the version number to the command in the tutorial?
  • I navigated back to my Code folder where I would put my Django project, and followed the tutorial (https://docs.djangoproject.com/en/1.5/intro/tutorial01/) for setting up a new project. But instead of django-admin.py, I tried django-admin-2.7.py. It worked!

这篇关于无法使用django-admin.py的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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