简体   繁体   中英

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. When I get to the step to run django-admin startproject mysite , I get the following error:

/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
  • 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.

As far as I can tell, it's trying to create manage.py twice, and the second time it's already there. Below is the content of the manage.py file that's created.

#!/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 version is 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.

Run 'pip uninstall django' twice, if it runs both times then this could be the case. 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.

My fix:

  • $ 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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