Django admin startproject не работает

django-admin.py startproject не работает

после установки django Я пробовал django-admin.py startproject mysite , и это сработало, затем я получил простой сайт, и я хотел начать что-то реальное, поэтому я попробовал django-admin.py startproject newsite , и ничего не произошло. Всякий раз, когда я пытаюсь выполнить команду, ничего не происходит сейчас.. любая идея, что не так?

10 ответов

Для тех, кто наткнулся на это сейчас, эта проблема возникает из-за того, что Windows не подчиняется #! C:\Path\To\Virtualenv\Scripts\Python.exe hashbang в верхней части django-admin.py и, следовательно, работает это с неправильным python.exe(очевидно, ошибка virtualenv).

Однако при активном действии virtualenv вы можете использовать следующую команду, которая приведет к использованию правильного питона, и все будет нормально:

Если вы используете Windows для быстрого исправления, вы можете создать командный файл со следующими значениями:

Я назвал файл «django.bat», и для его использования вы можете просто добавить копию в каталог, который хотите запустить проект, выполнить файл, и он попросит вас указать имя проекта, предоставить один, а затем Voila!

Надеюсь, что это поможет.

У вас есть набор переменных среды DJANGO_SETTINGS_MODULE (предположительно из проекта mysite )? Если да, то django думает, что вы работаете над старым проектом и не дает вам опцию startproject . Попробуйте отключить переменную окружения и повторите попытку.

Источник

Python-сообщество

Уведомления

#1 Сен. 25, 2011 11:15:35

Django не получается создать новый проект

Приветствую.
Возникла проблема с созданием нового проекта. При вводе команды django-admin.py startproject mysite, открывается файл django-admin.py, при этом ни какой проект не создается. Голову сломал, даже полностью переустанавливал Python, Django. Версия Python 2.7, django 1.3, Win 7 32. Принт рабочего стола прилагаю. ПОМОГИТЕ! не охото XP ставить.

#2 Сен. 25, 2011 12:59:55

Django не получается создать новый проект

в Path точно пути python и Scripts есть?

#3 Сен. 25, 2011 17:01:06

Django не получается создать новый проект

да пути прописаны.Не могли бы Вы помочь, создать чистый проект, заархивировать и кинуть на volandbaik@me.com, пойду по такому пути. Буду признателен.

#4 Сен. 25, 2011 17:27:52

Django не получается создать новый проект

volandbaik
да пути прописаны.Не могли бы Вы помочь, создать чистый проект, заархивировать и кинуть на volandbaik@me.com, пойду по такому пути. Буду признателен.

#5 Сен. 25, 2011 18:48:55

Django не получается создать новый проект

знаю что плохой! нет просто открывает файл django-admin.py c содержимым

#!c:\Python27\python.exe
from django.core import management

if __name__ == “__main__”:
management.execute_from_command_line()

и все…..
папку проекта с необходимыми файлами url setting …. не создает.
Перестановка Python Django не помогла…

#6 Сен. 25, 2011 20:41:09

Django не получается создать новый проект

попробуйте указать полный путь до django-admin.py и добавить в переменную path путь с папкой где лежит django-admin.py может поможет

#7 Сен. 25, 2011 23:00:44

Django не получается создать новый проект

люди киньте новый проект на volandbaik@me.com ничего не помогает(((

#8 Сен. 26, 2011 06:47:12

Django не получается создать новый проект

попробуй ввести “python django-admin.py startproject mysite”
а вообще не надо ничего скидывать, шаблон проекта лежит в исходниках джанго, можно просто оттуда скопировать

Отредактировано (Сен. 26, 2011 06:47:56)

#9 Сен. 26, 2011 16:13:23

Django не получается создать новый проект

спасибо всем ничего не помогло, решил делать с готового нового проекта.

#10 Сен. 30, 2011 13:04:04

Django не получается создать новый проект

делается это так:
1) заходим в папку где будем создавать новый проект
2) в консоли пишем: “python C:\Python27\Scripts\django-admin.py startproject mysite”
т.е. мы прописали путь к файлу django-admin.py(у вас может быть другая версия Pythona-у меня 2.7) а проект назвал “mysite”
3) проверим папку где создали новый проект

Отредактировано (Сен. 30, 2011 13:04:28)

Источник

Django admin startproject не работает

Здравствуйте! У меня перестала работать команда django-admin.py startproject (раньше работала отлично), выдает Usage: django-admin.py subcommand [options] [args] и т.д.

Причина, видимо, в том, что я недавно установил параллельно другую версию Python. Сначала получал сообщение об ошибке: Traceback (most recent call last): File «C:\python26\lib\site-packages\django\bin\django-admin.py», line 2, in from django.core import management ImportError: No module named django.core

Читайте также:  Toyota corolla не работает обогрев заднего стекла

Удалил лишнюю версию Python, теперь получаю то сообщение, с которого начал. Как исправить — не понимаю. Пользуюсь Windows 7, Python 2.6.6, Django 1.3. PATH=C:\python26\lib\site-packages\django\bin\; PYTHONPATH=C:\python26 На аналогичный вопрос в группе https://groups.google.com/group/django-users/ , вот тема: https://groups.google.com/group/django-users/browse_thread/thread/6fbeaa486de657a8/9295d515ce9f79ae?hl=ru&lnk=gst&q=startproject#9295d515ce9f79ae ответа не было, кроме констатации: if you tried the command django-admin.py startproject mysite and it output the usage, it mean the PATH of Python and django-admin.py is correct, maybe you type a wrong subcommand.

насчет неправильного написания подкоманды — это ерунда. Вот копия моего экрана: c:\DjangoMySites>django-admin.py startproject newsite Usage: django-admin.py subcommand [options] [args] Options: -v VERBOSITY, —verbosity=VERBOSITY Verbosity level; 0=minimal output, 1=normal output, 2=all output —settings=SETTINGS The Python path to a settings module, e.g. «myproject.settings.main». If this isn’t provided, the DJANGO_SETTINGS_MODULE environment variable will be used. —pythonpath=PYTHONPATH A directory to add to the Python path, e.g. «/home/djangoprojects/myproject». —traceback Print traceback on exception —version show program’s version number and exit -h, —help show this help message and exit Type ‘django-admin.py help ‘ for help on a specific subcommand. Available subcommands: cleanup compilemessages . (вырезал для краткости) startproject syncdb test testserver validate

Переменная DJANGO_SETTINGS_MODULE , вроде, не должна быть причиной, я ведь еще только создаю проект. Поэтому, если набрать ее имя в ответ на приглашение: c:\DjangoMySites>DJANGO_SETTINGS_MODULE то выводится не значение, как если набрать PATH , а: «DJANGO_SETTINGS_MODULE» не является внутренней или внешней командой, исполняемой программой или пакетным файлом.

Источник

django-admin.py startproject is not working

after installing django I tried django-admin.py startproject mysite and that worked, then I got a simple site working and I wanted to start on something real, so I tried django-admin.py startproject newsite and nothing happened. Whenever I try the command nothing happens now.. any idea what is wrong?

14 Answers 14

For anyone stumbling across this now, this problem is a result of Windows not obeying the #!C:\Path\To\Virtualenv\Scripts\Python.exe hashbang at the top of django-admin.py, and therefore running it with the wrong python.exe (evidently a virtualenv bug).

However, with virtualenv active, you can use the following command, which will result in the correct python being used, and everything being ok:

works without using virtualenv — Thanks!

If you are running Windows for a quick fix you can create a batch file with the following values:

I named the file «django.bat» and to use it you can just simply add a copy in the directory you want to start the project, execute the file and it will ask you for a project name, provide one and then Voila!!

Hope this helps.

Do you have a DJANGO_SETTINGS_MODULE environment variable set (presumably from the mysite project)? If so, django thinks you’re working on the old project and doesn’t give you the startproject option. Try unsetting the environment variable and trying again.

For me worked without .py extension, since there was .exe by that name in my windows:

If everything is installed properly, when you open the command prompt, navigate to the desktop folder with

The project should appear on your desktop.

If you didn’t navigate to your desktop folder and run the command there, your project could be placed in the windows\system32 folder on the C drive.

Go on to c:/python**/Scripts/ you must find django-admin.py there that fixes your problem use the absolute path.

Try this instead! It also works inside virtualenv

Try for this commond:

django-admin startproject mysite

instead of django-admin.py startproject mysite.

I’m on a Mac and had a similar problem after installing with pip3. I reinstalled and it corrected the error. You can try going to the #django irc channel at irc.freenodes

Try out this way.

1> Look where your python is installed if cannot find it in C:/ Python().

2> After that move into Scripts folder. There you may find django-admin.py. Now copy full path of that file.

3>Now run this command

python path of the file startproject name of Project

eg. python C:\Users\UserName\AppData\Local\Programs\Python\Python35-32\Scripts\django-admin.py startproject mysite

hope this will work.

after years I have to answer this question because the answer is changed for WINDOWS now

you can use .exe for windows in Scripts folder

Even I faced the same problem. I even tried adding the directory to Environmental variables but it was not working, so I had to use python -m django for it, but it didn’t satisfy me, so I did a tricky thing.

Instead of adding the directory to Environmental variables, I copied the installed package and pasted it to the first directory (default directory) in environmental variable and it started working.

Читайте также:  Микроволновка националь как настроить время

Источник

command «django-admin.py startproject mysite» not recognized

EDIT: I added the path to django-admin.py to my system path (C:\Users\me\Downloads\Django-1.5.1\django\bin) but even after this when I try to run django-admin.py startproject mysite, it asks me to pick a file to open with and even when I pick python.py, it opens in chrome for some reason. I also tried python django-admin.py startproject mysite but it says

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

Any idea what is wrong?

I added python27 to the system path and when I open up cmd and switch to a directory (C:\Users\me\djcode) and then type in django-admin.py startproject mysite it says

django-admin.py is not recognized as an internal or external command, operable program or batch file

When I try typing the command python django-admin.py startproject mysite, it says

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

django-admin.py should be on your system path if you installed Django via its setup.py utility

what does this mean? how do I add django-admin.py to my system path? I am not sure where django-admin.py even is.

25 Answers 25

Working !!
If you are using window then first of all

create virtual environment

Then activate that environment

Then install Django in that environment

Then create django project named mysite

Find the folder where django-admin.py is located. Then go to Control Panel > System > Advanced System Settings > Environment Variables . In the User Variables and/or System Variables, search for an entry called PATH. Modify it by adding the folder you found earlier, use the other entries as guidance, basically just make sure they’re separated by ; . If you have done all these steps, but are still in the same cmd prompt that you were using before doing them, close it and open a new one so it picks up on your changes.

I have the same problem because i have installed Django Manually. The solution for resolve :

  1. Install Python https://www.python.org/downloads/ (if not installed)
  2. Verify your Path : https://stackoverflow.com/a/17836439 It’s very important or the next no work.
  3. Install setuptool : Download the .py file here : https://bootstrap.pypa.io/ez_setup.py and execute this with python.
  4. Install PIP with this command : easy_install pip
  5. Clean Django : pip uninstall django
  6. install Django : pip install django
  7. Execut django-admin.py startproject mysite and enjoy.

If not OK, test django-admin-script.py startproject mysite . If is ok, your django installation is wrong.

Sorry for my bad english, i’m french 🙂

For windows, the «django-admin» you need to create a project is an .exe file not a .py file and it is present at the following location: C:\Python27\Scripts so you have to add this location to your path.

Try this: django-admin startproject mysite

After running pip install django wait for the setup to finish and present you with a warning.

From the warning copy the path of where django is installed. In my case it is C:\Users\USERNAME\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8\LocalCache\local-packages\Python38\Scripts

Add that to PATH in environment variables and restart cmd or shell.

If it did not work for you even if you tried the command :

django-admin startproject mysite

Here’s what worked for me:

  • Add the below path to the PATH variables-

Note: In the above path, System_Name refers to the name of your laptop/pc.

You can check the version of django using django-admin —version

You need to install django. It seems you have just downloaded it and expanded the archive.

  1. Install setuptools
  2. Install pip
  3. Open a command prompt and then type pip install -U django (or, you can download the windows installer).

Once you have done the above steps, you need to make sure C:\Python27\Scripts is in your PATH ; otherwise the commands will not work.

To set PATH , go to Environment Variables from My Computer (right click and then go to Manage, then on the left, Advanced Settings).

Finally, you’ll need to run python django-admin.py and not django-admin.py

this one workked for me python 2.6.6 django 1.6.11 python C:\Python26\Scripts\django-admin.py startproject myapplication

Try using. exe instead of .py. It worked for me

copy the Django-admin.exe file into the folder you are using. the file can be found at python/python(version)/scripts. when you finish a folder should pop up in the name of your file

Just copy the Django admin.py file which is present actually where you have installed python in C:\program files\Python or in my case it was located at administrator\appdata\local\programs\python you can check yours and just copy the file that is Django admin from script folder to your newly created folder

I needed to update my System Environment Variable path so this answer helped me:

Читайте также:  Не работает destiny ps4

You will have to activate the environment (env) before you run the command: django-admin startproject myapp

I had the same problem.

For Windows user:

Step 1: Open cmd in the project directory

Step 2: Run this in cmd : python -c «import django; print(django.__path__)»

Step 3: Go to the path and copy django-admin.exe to the current project directory

Step 4: Run this in cmd : django-admin startproject DEMO

Happy Learning,

Before you run django-admin.py startproject mysite

1) You need to create a virtual enviroment on the folder that you want to store your project so run pipenv install django==2.1 (if you dont have pipenv installed run pip install —user pipenv )

2) To run this virtual enviroment run pipenv shell

3)And finaly django-admin.py startproject mysite

Hope this works

In my case I made a mistake installing django in a wide system manner and then it created /usr/local/bin/django-admin I uninstalled django through pip but it doesn’t remove those files then when you type the command it tries to invoke that file but as it says the module django is not present.

Just remove those orphans files (use sudo if needed)

and try again (with your virtualenv activated) and it should takes the right module and works as usual!

I’ve just created project using : py -m django startproject Yourprojectname

This is my solution:

For me, a simple fix was reinstalling python. It turns out I didn’t select add to path, when installing python the first time, and that is crucial.

if you are using windows then goto (search)»advanced system settings/Environment veriables/New path» and add path of your python packeges folder, in my case its «C:\python38\Lib\site-packages». may be you have other path of site-packages folder.

If you are using Pycharm then after creating New project just go to the file—>setting—>project—>serch Django—>install Django then go to the terminal type django-admin startproject name(whichever you want) press enter

Run CMD as Administrator
pip3 install django

If you had this error occur on windows after installing django using pip that has the message along the following lines:

could not install packages due to an OSError: [WinError 2] The system cannot find the file specified: ‘c:\python39\Scripts\sqlformat.exe’ -> ‘c:\python39\Scripts\sqlformat.exe.deleteme’

Which in turn causes the same problem as the question stated. A working solution is to clean installing django which you can do by using pip uninstall django , and then reinstalling it by running the install command like this: pip install —user django .

If no other warnings or errors occur, then it should be fixed. In case a warning sating that the django-admin.exe file is located at some location that needs to be added to the path variable, you can copy that path and add it to the path variable under your environment variable settings.

Quick fix guide:

  1. Uninstall django: pip uninstall django .
  2. Reinstall django: pip install —user django .
  3. If a warning occurs containing a path continue to step 4 otherwise it should be fixed, and you may skip to the bottom.
  4. Copy the path that should be added to the PATH environment variable.(the one specified in the warning)
  5. Click on the start menu button.
  6. Search for Control Panel and click on it.
  7. Change the View by: option to Large icons .
  8. Click on the System item.
  9. Click on the Advance system settings button.
  10. The System Properties window will open, proceed to click on the Environment Variables. button at the bottom right.
  11. A new window will open displaying your Environment Variables, on the first gird select the row with the name of PATH or Path or path under the Variable column.
  12. Then click the Edit button just below the grid.
  13. A new window will open, proceed to click on the New button and paste the path you copied earlier.
  14. After pasting press the Enter key and proceed to click on the OK button.
  15. Once the window closes and you’re back in the Environment Variables window proceed to do steps 11 to 14 again only with the grid at the bottom(inside the System Variables group).
  16. Once all these steps were followed you may click on the OK button in the Environment Variables window and close out of all the other windows that are still open after you followed these steps.
  17. Close your CMD window and open a new one (this allows it to recognize the changes you made to your environment variables).

After following these steps, you should be able to continue with what you were doing without having any other difficulties further regarding Django

Источник

Оцените статью