I am a total newbie when it comes to django. However I have experience with python, I know how to install modules etc. I work on Win7 x64 with Python 2.7
Here is what I did:
Made sure Python environment variable is Set in %PATH%
installed django with pip install Django and checked afterwards if it installed (1.5.4)
added C:\Python27\Scripts to the environment variables (django-admin.py is there)
restarted cmd
enter django-admin.py help - no Error nothing, jumps to next line
enter django-admin.py startproject mysite - no Error, no Folder created, jumps to next line
enter django-admin.py gsfögjsdfüoisudhihdsf - no Error, nothing jumps to next line
did a pip uninstall Django and reinstalled it with pip install Django and tried started again at point 1
So now I have no idea what could be wrong. I even checked if the from django.core import management in the django-admin.py works - it does.
Any ideas?
Edit: Solved it by changing the .py associations. If you still encounter an error (like I did) go How to edit file associations
Related
I am a beginner to coding and decided to start with Python. I am following 'Intro To Django with Python For Web Development' by coderschool on youtube as my first project. When I enter django-admin.py startproject mysite into the PowerShell prompt, I get a 'modify setup' pop-up from the Python programme.
I have tried everything I can think of, including Modifying, repairing, uninstall and re-installing but I still keep getting the same pop up. How can I get this to work properly?
Try using django-admin startproject mysite instead of admin.py.
Django docs -
If you installed Django using a Linux distribution's package manager (e.g. apt-get or yum) django-admin.py may have been renamed to django-admin. You may continue through this documentation by omitting .py from each command.
I am running Windows 10 and admin.py won't work for me, so I don't think its limited to Linux distros.
First of all I want to assure you that I have in fact python 3.5.1 and django 1.9.
I installed python with an installer which automatically added python to my PATH (I have checked this).
I ran into a problem with pip,
Every time in CMD when I enter, even the word pip the cmd window just stands still, no error, nothing, it is just pretending to load, doesn't even let me type in anything else, can't even be "ended" with Task Manager.
Eventually I found a work-around with
python -m pip install virtualenv
That worked, I made a ENV, activated it, installed django with the same command, but now when I try to enter this command:
django-admin.py startproject Concept
It doesn't work, if I try with
python django-admin.py startproject Concept
It will say that the file is missing.
Every time I run this command in my text editor, sublime 3, the django-admin,py file opens, at the top of the document I saw
#!C:\Users\filip\Python\ENV\Scripts\python.exe
So, I tried changing it to
#!C:\Users\filip\AppData\Local\Programs\Python\Python35\python.exe
That didn't work either, hope you can help.
python C:\Users\filip\Python\ENV\Scripts\django-admin.py startproject Concept
This works, apparently it is a Windows bug.
I'm following along with the djangoproject.com tutorial. I used pyCharm to setup a dummy project.
on my terminal command line I cd into the folder that has manage.py i then run the line.
python manage.py startapp polls
I get this error:
Traceback (most recent call last):
File "manage.py", line 8, in <module>
from django.core.management import execute_from_command_line
ImportError: No module named django.core.management
What is this and why can't I create another app called polls?
In my case, I already have installed Django, but I type "runserver" command from virtualenv and it showed the same error that Chapsterj
I resolved typing this:
(venv)$ pip install Django
Before, To enter in virtualenv, type this:
$ virtualenv venv --distribute
$ source venv/bin/activate
(venv)$
I've never heard of PyCharm, but as the comments suggest, this means the python interpreter cannot find django.
One thing to try - open up a terminal (anywhere) and type:
python
then run
import django
If you have django installed, this should work; otherwise it will not.
In my case, I run all of my django installs via virtualenv (basically, localised versions of the python package index so different projects can have different versions of packages installed) so doing this from any old terminal for me doesn't work.
In my case, I then need to make an adjustment to the PYTHONPATH environment variable. Well, actually, I'm lying slightly, virtualenv is a little more complicated than that, but that's another way to make it work.
So, I would suggest:
Making sure you have django installed in your python site-packages directory (where most third party packages live). Usually, something like yum install python-django or pip install Django will do this for you.
If this is not where you've installed Django, edit your PYTHONPATH first in a shell session (to make it easy to test and get right) and then in your IDE so python can find it.
If the IDE doesn't provide you with a way to edit the pythonpath variable, you should be able to manage this by editing manage.py like so:
import sys
sys.path.append('/opt/Django')
# the rest of manage.py ...
import django
To properly install django you must use the "superuser", try
sudo pip install django
Hope it helps
On Rhel6, umask prevented the django directory from being accessed, so I had to run:
cd /usr/lib/python2.6/site-packages/django/
find django -type d | xargs chmod 775
find django -type f | xargs chmod 664
and add /usr/lib/python2.6/site-packages/django/ to my path in .bash_profile.
I see no accepted response to this and since it is not so much a Django question as it is a PyCharm question, I'll add my 2c in case others are having the same problem getting started.
I am also running through the "Writing your first Django" tutorial using PyCharm and I am not having these problems. I WAS having all sorts of problems until I realized that you let PyCharm create everything and the problems go away ;-)
So far, I am reading both the PyCharm AND the Django tuts together. PyCharm tut is here: https://www.jetbrains.com/pycharm/help/creating-django-application-in-a-project.html
YOUR problem may be answered with this:
To add a new django application to an existing project
On the main menu, choose Tools | Run manage.py task
In the Enter manage.py task name dialog box, type startapp. Note suggestion list that appears under the dialog box after entering the first letter, and shrinks as you type to show the exact match only.
In the dialog box that opens, type the name of the new Django application.
I had a same problem with PyCharm, what I did was:
Go to File -> Default Setting ->
Project Interpreter (Pick python 3...) if thats what you want to use
It will show all packages available
Double click on Django
Install Package.
Then in terminal instead of
python manage.py migrate
tape
python3 manage.py migrate
when i type in the command prompt
django-admin.py startproject mysite
the django-admin.py will open automatically with pype,
now if i type cd mysite it says the system cannot find the path specified
I'm using activepython (i don't think that activepython has anything to do with it), django installed using pypm. I can create a project in pydev, not in the command prompt, about a year ago when i first installed activepython, it used to work but as far as i can remember i deleted a django project and it won't work anymore.
how to fix it?
EDIT
#Mikko Ohtamaa
mysite folder does not exist,i see on pype that it has opened the file from C:\Documents and Settings\Administrator\Application Data\Python\Scripts\django-admin.py
but the path is incorrect i don't have an application data folder in C:\Documents and Settings\Administrator\
I have searched the entire pc and haven't find a folder, furthermore in you run this 100 times
django-admin.py startproject mysite
it will keep opening a file called django-admin.py you know, nothing else
"but the path is incorrect i don't have an application data folder in C:\Documents and Settings\Administrator\"
This would mean that your Python or Django installation is corrupted (probably due to reinstall Python).
Try go to square zero and reinstall both Python and Djangon on your computer. Also if it still does not work please describe how did you install both of them.
new one to me
commend
I'm running ubuntu 10.04 relatively fresh install on my laptop
manually installed django 1.2.1
when I try to run inside of a virtualenv
python manage.py **any command**
I get the error "bash: /home/alvin/workspace/storm-guard/virtual_damage_restoration/bin/python: cannot execute binary file
"
I have done the following so far:
removed and re-installed django
removed and re-installed project directory
removed first line from manage.py that defines the python shell to use
verified file has permission to execute
re-installed virtualenv
at this point I'm scratching my head
any advice is greatly apreciated
the virtualenv I was attempting to use was copied from another computer
for whatever reason when I created a new virtualenv and copied the bin directory over the existing everything started working