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)
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With