I have been running my python server for a few months now and I have had no problems, but ever since I have installed react-native I now get the following error. I don't know if the python problem is related to the installation of react-native but it seems like a bit of coincidence.
Any help in solving this issue would be appreciated
File "manage.py", line 14
) from exc
^
SyntaxError: invalid syntax code here
My manage.py file:
#!/usr/bin/env python
import os
import sys
if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my_website.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
I fixed this my installing python 3.7 and running
py -3 manage.py runserver
I also had to reinstall the packages that were being used on my project
You are trying to use a Python-3-specific Django version with a Python 2 interpreter. You will clearly see that if you look at the top of the full stacktrace
raise ... from ...
is a Python 3 syntax. A Python 2 interpreter will treat it as a SyntaxError
as can be demonstrated here .
Make sure you are using Python 3 to execute this server.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.