I'm trying to set up a repo locally but facing an issue i.e python manage.py runserver command gets aborted as soon as I hit localhost URL (http://127.0.0.1:8000/)
error - [1] 7398 abort python manage.py runserver
Django version 1.6.6
Python 2.7
OS -> MacOS Catalina (10.15.3)
Database postgres (PostgreSQL) 12.2
first why ur using old version python and Django. that's first because they didn't have support so I strongly recommend you to upgrade newest versions
I think this is due to Python & Catalina incompatibility. Try using Python 3.7. Similar question
In general, try to avoid using Python 2.x. Insted use Python 3.7.x.
Related
I am attempting to run a Python Flask server in Git Bash. When running this server outside of Git Bash, I use PyCharm and I have no issues. However, I am attempting to deploy my program into a server and am using Git Bash for that. I have done everything else perfectly and running the server in Git Bash is the last step required in my deployment. I believe the error is my Python version and I am following a tutorial video where in the video, the user is using Python 3.6.9 while my Git Bash, by default, is using Python 3.8.10. I have tried to change my Git Bash python version down to 3.6.9 but I have not found a good tutorial or steps on how to do that.
Requirement.txt has:
Flask==1.0.2
numpy==1.20.0
scikit-learn==0.20.3
This is the error I get when attempting to run my server.py
Any help would be greatly appreciated! Thank you
EDIT: I got it to work after simply updating the scikit-learn module to version 0.24.1
Updating scikit-learn module to version 0.24.1 solves this issue
When I am running command python3 mange.py runserver I am getting error improperly configured SQLite 3.8.3 found 3.7 .
Django version is 3.
I also checked similar problems on stackoverflow but in my case it doesn't work
TL;DR: python versions conflicts, i think that the python i downloaded and compiled (3.6) can't use this package (libmysqlclient-dev) to make migrations to mysql. only the system's default python (3.4) can.
my ubuntu server came with python 3.4, all of my django work and other work depend on 3.6. i have learned that upgrading system python is a bad idea, so i compiled python 3.6 (with altinstall).
when i ran python3.6 manage.py migrate it gave me this mysql error:
_mysql_exceptions.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '(6) NOT NULL)' at line 1")
i tried virtual environment and normal python 3.6, both gave the same error, and i made sure that libmysqlclient-dev and mysqlclient are installed.
as this answer suggests, the problem is with libmysqlclient-dev because it's installed via apt-get not pip so i guess it's only compatible with the default python (3.4 that came with the system) or my compiled python 3.6 isn't allowed to use it, because when i made a dummy django project with python3.4 (system's default) and attempted python3.6 manage.py migrate on the same mysql database with the same user, it worked!
AGAIN: my problem is that the manually compiled python 3.6 can't use libmysqlclient-dev that has been installed by apt-get, only 3.4 can
reference: Django MySQL error on migrate
UPDATE
i came up with a work around but it's not efficient. i downgraded Django to 2.0.9 and it (python manage.py migrate) worked. but this problem could appear again with a different package.
Django 2.1.* requires MySQL 5.6 or higher. It broke the compatibility by mapping DateTimeField to datetime(6).
You can patch Django MySQL data type mapper. Put this to the top of your settings.py
from django.db.backends.mysql.base import DatabaseWrapper
DatabaseWrapper.data_types['DateTimeField'] = 'datetime' # fix for MySQL 5.5
There is a major difference in the support for django 2.0.* vs django 2.1.*
AS per Django 2.0.* MySQL Notes
Django supports MySQL 5.5 and higher.
As per Django 2.1.* MySQL Notes
Django supports MySQL 5.6 and higher.
Check you MySQL version with: mysql -V and use the correct django version.
from django.db.backends.mysql.base import DatabaseWrapper
DatabaseWrapper.data_types['DateTimeField'] = 'datetime' # fix for MySQL 5.5
Solved my problem!
Thanks Luka Zakrajšek
I just installed django and after installing that I created a django project and was trying to run django server by command:
python manage.py runserver
After that I'am getting error as:
SyntaxError: Generator expression must be parenthesized
TL; DR: Upgrade Django to version 1.11.17+ or 2.0+
This error is a known incompatibility related to Python issue #32012. Projects based on Django 1.11.16 and below will raise this exception when started with Python 3.7. A patch for this issue has been merged into Django 2.0 and 2.1 branches and cherry-picked later into Django 1.11.17.
Note: Python 3.7 is officially supported by Django 1.11.17 and above, including any 2.x branch.
Generator expression must be parenthesized
> Update Django version to 1.11.17
pip install django==1.11.17
Had same issue. This is how I changed to django version 2.0 and used python3
$pip3 install django==2.0
$python3 manage.py runserver
Install this version: pip install django==1.11.17
Run cmd.
go to your project folder.
python manage.py runserver
it will give a URL for server and you are good to go.
This is due to the version incompatibility.Just we need to upgrade the Django version to 2.1.
Run the command in cmd:Pip install django==2.1. this will resolve the issue
I just faced an Error like this. I was using Django-1.11.10. I deleted it and installed Django 2.0
Problem is solved.
But if you are using ForeignKey in you model.py files it must be problem again. You should update your coding to 2.0 versiong insted of older versiyon.
Example:
django older version
user = models.ForeignKey('auth.User', related_name='posts')
django 2.0
user = models.ForeignKey('auth.User', related_name='posts', on_delete=models.CASCADE,)
I had the same issue and I realized it is due to the compatibility of the Django version I was working with. So I had to state the Python version explicitly like this: >python3.6 manage.py runserver
Just open file:
venv/lib/python3.7/site-packages/django/contrib/admin/widgets.py
and replace the lines
related_url += '?' + '&'.join(
'%s=%s' % (k, v) for k, v in params.items(),)
with
related_url += '?' + '&'.join('%s=%s' % (k, v) for k, v in params.items())
I have installed on Win7 portable Python 2.7.5.1 and Django 1.6.
I followed the first polls tutorial instructions and got an error in the migrate stage, python manage.py migrate:
C:\Natan\Dev\Portable Python 2.7.5.1\App\Scripts\mysite>..\..\python.exe manage.py migrate
Unknown command: 'migrate'
Type 'manage.py help' for usage.
Any idea?
If you've installed 1.6, you should use the 1.6 tutorial, not the one for the development version.
First Step, Install South:
pip install south
Second Step, Add South to INSTALLED APPS in settings
INSTALLED_APPS = (
...,
'south' )
Migrate will be a native command in 1.7 (which is the version you read the tutorial pages from).
For older versions, you'll have to install the third party app"South".
All-
This is likely caused largely by following the 1.7 (DEV version!) tutorial when we all get the last stable version (1.6!) installed by pip.
It would not appear migrate is even a part of 1.7 in general! Will:
python manage.py syncdb
Solve your problems?
So pls either follow the tutorial for the last stable version of django: https://docs.djangoproject.com/en/1.6/intro/tutorial01/
Or follow the instructions to install the dev version of Django.
Dear Django team,
You guys are awesome. The JS developer is very impressed. But PLEASE resolve the discrepancy above. Maybe default to 1.6 docs and put in red letters: Dev version here?
Thank you.
You must install South to add migrate command.
pip install south
If you are using Django older versions before 1.7 then you should sync database by
python manage.py syncdb
while in new versions after 1.7 syncdb is replaced by migration. So for syncdb in new django version is replaced by :-
python manage.py makemigrations
python manage.py migrate
for more type:-
python manage.py help