Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: 'python manage.py runserver' gives "Segmentation fault" error

Tags:

python

django

I just installed Python and Django for the first time while following this tutorial on the Django site, and everything up to this part worked just fine and produced no errors.

Now I'm at the "The development server" section, and ran the command python manage.py runserver while in my project directory where the manage.py is located and I get this error:

Segmentation fault

Nothing else.

Anyone know what's going on here and how I can solve this?

If it matters, this is my manage.py file (the django in the from django.core.management ... line is marked as an error in my IDE (PyCharm) and the error says Unresolved reference 'django'):

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

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

    from django.core.management import execute_from_command_line

    execute_from_command_line(sys.argv)
like image 734
Lansana Camara Avatar asked Jan 12 '16 04:01

Lansana Camara


2 Answers

This happened to me in a Django project where I had a lot of packages that had C-extensions. After I ran an Ubuntu system package update, I suddenly found that the manage.py command seg faulted. Turns out, some C-extensions link themselves to system libraries, and if a package update changes those libraries, it could cause the C-extensions to crash.

Since I had installed everything inside a Python virtualenv, I just deleted and regenerated it, and that fixed the error.

like image 96
Cerin Avatar answered Sep 28 '22 08:09

Cerin


I had this same issue following the tutorial pretty much verbatim (except that I am using git-bash in Windows, and used "virtualenv" in place of "mkvirtualenv" and "source projectdir/Scripts/activate" in place of "workon projectdir".

Running

python -vvvvv manage.py runserver

Gave me the warning that I had migrations that needed running (which the tutorial says to ignore) with

python manage.py migrate

Which is presumably not a step you can really skip in some cases, despite what the tutorial says. After this, runserver worked without error.

like image 21
VaelynPhi Avatar answered Sep 28 '22 06:09

VaelynPhi