Django server isn't working on the command: python manage.py runserver (on providing the port number as well)
I'm using windows 8, the path is set in environment variables. I've tried re-installing both python and django but it didn't help.
I share the similar problem. I solved it by just running Python 2.7x.
While working with the runiserver
python manage.py runserver --noreload
also worked for me - at least for a while. Maybe install an older version of Django?
I've not literally found a solution...
however it worked when I used python 2.7.13 (this creates a folder where you've scripts, easy_install etc., but I couldn't find a folder "Python" when I was using Python 3.6.1)
Related
IM trying to make a website with django and im following a tutorial that is telling me i need to tell my cmd prompt what version of python im using. this is the video https://www.youtube.com/watch?v=FNQxxpM1yOs at the 10:46 mark he says to put C:/Python35/ python manage.py runserver. I am putting thi but it is not working. I am using version 3.7 so i replaced 35 with 37 but it is still not working. can someone please helps with this.
Not sure if it's different depending on OS, but I'm on Linux and use python3 manage.py runserver since I have python 2 and 3 installed. Using just python tries to use python 2, which I'm guessing isn't the version of Django you installed. I also use pip3 when I need to.
It seems like you are on Windows, you can do where python in your shell (which is pretty similar to which command on Linux) to locate your python.
If you installed python correctly then python should be already in your $PATH, in this case, as suggested by #marsonfire, just run python manage.py runserver or python3 manage.py runserver in your project folder.
I have 3 django projects (version 1.11.15), and all errors after I accidentally install Python 2 (I installed the react native), before I used python 3.6.5 via Anaconda.
Some of my project files appear error symbols. And when I try to run "manage.py runserver", it can't run, and an error appears. I uninstalled Python 2, and reinstalled my Anaconda (Python 3.6.5), but it didn't work.
In my opinion there is a problem in the path, but I don't know what that is. I've been looking for a solution, but nothing works. Anyone has a solution? ... thanks
my python version
this is my python path, I don't know what to add here, I just followed a few tutorials that I found
this is my path
This is my requirement.txt
enter image description here
i found it,
it's " python manage.py runserver " not " manage.py runserver "
I have ran into this problem and I found the easiest solution was to write out requirements.txt and remove any unwanted libraries. Then delete the virtualenv and recreate a new with the new requirements.
I've written a django site in python 3.2 and I want to run it by Gunicorn in my VPS with Ubuntu 12.04 OS and I faced errors for that belongs to python 2.7 but since it's not a good idea to change my default python to 3.2 in Ubuntu 12.04 I want to ask is there anyway to tell Gunicorn to run my project by python 3.2 not python 2.7?
Sure, install the other python, but don't change your ubuntu settings. When you create your virtualenv for your django project, use the -p flag to specify which python to use.
virtualenv -p /usr/bin/python3.2 [path/to/new/virtualenv/]
Alternatively, move the whole project to Heroku. There you can specify things such as python version, plus you can start ignoring a whole bunch of dev-ops stuff like this and spend more time writing your app. It's free, and you can get set up in a couple of hours.
I'm having trouble setting up the correct python version for mod_wsgi / django setup.
After numerous bugs I think i'm nearing the end of this tedious setup... I'm trying to run a command from my manage.py file using ./manage.py collectstatic
This is failing because it's trying to use the Python 2.4 version (I have 2.7 installed as well), I believe the version error only occurs when i manually try and run manage. My django.wsgi file inserts the python 2.7 dir into sys.path
Thanks for your help
python2.7 manage.py collectstatic worked. Thanks to Display Name for the comment
I need to use Django 1.2 for one of my projects.
I also already have several projects running on Django 1.3 on the same server, and I need to keep them running.
Is there a way to only use 1.2 for a specific project?
Both sites run on Apache via mod_wsgi.
Consider installing Django inside a virtualenv. This will make the installation of python modules, including Django, completely independent of the rest of the system. This way, if you have multiple virtualenvs, you can have as many versions of Django installed (one per env).
To use a virtualenv, you shold edit your index.wsgi and add the following two lines before any other line that imports or references Django:
activate_this = '/path/to/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
This is assuming that you are not using different version of the python interpreter itself, which is possible using virtualenv, but would make things quite a bit more complicated.
Yes. Django is just a regular Python module living in your site-packages. So when you import django.something, the way Python decides which version to load is by walking down the Python path (import sys; print sys.path) in order and looking for a directory called django (with something.py or something/_init_.py inside). It loads the first one it finds. So the quickest method is to modify this Python path before starting your project, which can be conveniently done with an environment variable named PYTHONPATH.
So for your Django 1.2 project, install Django 1.2 in site-packages/django-1.2 and then:
# run Django 1.2 for old app that I don't have time to update
cd ~gaearon/src/old-django-project
env PYTHONPATH=/Library/Python/2.6/site-packages/django-1.2 ./manage.py runserver
For all other (Django 1.3) projects, simply install Django as normal, which makes it the default:
# all other projects use the system default Django 1.3
cd ~gaearon/src/current-django-project
./manage.py runserver
For production servers you won't use runserver, but the PYTHONPATH will work wherever you invoke Python (i.e. flup, or manage.py runfcgi). If invoked from mod_python there is an Apache configuration directive to modify the Python path (see mod_python documentation).
Or you could use virtualenv.
When I need to do stuff like this I have found that virtualenv combined with virtualenvwrapper helps a lot.
> mkvirtualenv django1.2
> cd django-1.2-dist-dir
> python setup.py install
> mkvirtualenv django1.3
> cd django-1.3-dist-dir
> python setup.py install
Now both Django versions are installed in their own virtual environments. To use a specific one do:
> workon django1.2
or
> workon django1.3