简体   繁体   English

django-admin startproject试图创建两次manage.py?

[英]django-admin startproject trying to create manage.py twice?

I'm trying to work through the Django tutorial for version 1.9, running on Ubuntu 15.10. 我正在尝试使用在Ubuntu 15.10上运行的版本1.9 的Django教程 When I get to the step to run django-admin startproject mysite , I get the following error: 当我到达运行django-admin startproject mysite的步骤时,我收到以下错误:

/home/.../manage.py already exists, overlaying a project or app 
into an existing directory won't replace conflicting files

A Google search shows I'm not the first one to ask this question, but the answer is always "it looks like you're trying to create a project with the same name. Delete the old project or pick a different name." 谷歌搜索显示我不是第一个提出这个问题的人,但答案总是“看起来你正在尝试创建一个同名的项目。删除旧项目或选择一个不同的名称。” Unless there's something big I'm missing, that's not my problem. 除非有一些我失踪的大事,否则这不是我的问题。 This is the first and only project I'm trying to create. 这是我想要创建的第一个也是唯一一个项目。 I've tried using different names and creating projects in a number of different directories, and the result is always the same. 我尝试使用不同的名称并在许多不同的目录中创建项目,结果总是一样的。 Each time it fails, I clear out the pwd. 每次失败,我都会清除掉密码。 Here's what happens: 这是发生的事情:

  • before I run django-admin startproject mysite , the pwd is completely empty, no hidden files either 在我运行django-admin startproject mysite ,pwd是完全空的,也没有隐藏文件
  • after I run the command, there is a directory called mysite with the file manage.py in it, but there is no mysite/mysite package. 在我运行命令之后,有一个名为mysite的目录,其中包含manage.py文件,但是没有mysite/mysite包。

As far as I can tell, it's trying to create manage.py twice, and the second time it's already there. 据我所知,它试图创建两次manage.py ,第二次它已经存在。 Below is the content of the manage.py file that's created. 以下是创建的manage.py文件的内容。

#!/usr/bin/env python
import os
import sys

if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")

from django.core.management import execute_from_command_line

execute_from_command_line(sys.argv)

My django-admin version is 1.9.5 我的django-admin版本是1.9.5

Django version is 1.9.5 Django版本是1.9.5

What's the problem if it's not trying to create two projects with the same name in the same directory? 如果没有尝试在同一目录中创建两个具有相同名称的项目,会出现什么问题?

I think you've got two versions of django installed, and both are being called when starting a project. 我认为你已经安装了两个版本的django,并且在启动项目时都会调用它们。

Run 'pip uninstall django' twice, if it runs both times then this could be the case. 运行'pip uninstall django'两次,如果它运行两次,那么情况就是如此。 You can then reinstall the version you want to get it working. 然后,您可以重新安装要使其运行的版本。

I have some problem, and " sudo pip uninstall Django " do not help me. 我有一些问题,“ sudo pip uninstall Django ”对我没有帮助。

My fix: 我的修复:

  • $ python -c "import django; print(django.__path__)" result: ['/usr/local/lib/python2.7/dist-packages/django'] $ python -c "import django; print(django.__path__)" result: ['/usr/local/lib/python2.7/dist-packages/django'] $ python -c "import django; print(django.__path__)" result: ['/usr/local/lib/python2.7/dist-packages/django'] $ python -c "import django; print(django.__path__)" result: ['/usr/local/lib/python2.7/dist-packages/django']

  • $ sudo rm -r /usr/local/lib/python2.7/dist-packages/django

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM