12
You’re going to want to add Python to your Path Environment Variable in this way. Go to:
- My Computer
- System Properties
- Advance System Settings
- Under the “Advanced” tab click the button that says “Environment Variables”
- Then under System Variables you are going to want to add / change the following variables:
PYTHONPATH
andPath
. Here is a paste of what my variables look like:
PYTHONPATH
C:\Python27;C:\Python27\Lib\site-packages;C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\Python27\Scripts
Path
C:\Program Files\MySQL\MySQL Utilities 1.3.5\;C:\Python27;C:\Python27\Lib\site-packages;C:\Python27\Lib;C:\Python27\DLLs;C:\Python27\Lib\lib-tk;C:\Python27\Scripts
Your Path’s might be different, so please adjust them, but this configuration works for me and you should be able to run MySQL after making these changes.
- [Django]-Data Mining in a Django/Postgres application
- [Django]-South migration: "database backend does not accept 0 as a value for AutoField" (mysql)
- [Django]-How to change the Django admin filter to use a dropdown instead of list?
60
If you are trying to use mysqlclient
on WINDOWS with this failure, try to install the lower version instead:
pip install mysqlclient==1.3.4
- [Django]-Django change default runserver port
- [Django]-Request.user returns a SimpleLazyObject, how do I "wake" it?
- [Django]-Django Rest-Framework nested serializer order
15
if you use the site http://www.lfd.uci.edu/~gohlke/pythonlibs/#mysql-python , download the file:
-
mysqlclient‑1.3.6‑cp34‑none‑win32.whl or
-
mysqlclient‑1.3.6‑cp34‑none‑win_amd64.whl
depending on the version of python you have (these are for python 3.4) and the type of windows you have (x64 or x32)
extract this file into C:\Python34\Lib\site-packages and your project will work
- [Django]-How to hide some fields in django-admin?
- [Django]-Running Django with FastCGI or with mod_python
- [Django]-In the Django admin interface, is there a way to duplicate an item?
14
There are windows installers for MySQLdb avaialable for both 32 and 64 bit, supporting Python from 2.6 to 3.4. Check here.
- [Django]-Django Rest-Framework nested serializer order
- [Django]-How can i set the size of rows , columns in textField in Django Models
- [Django]-Custom error messages in Django Rest Framework serializer
4
For folks using Python 3.0+ (which should be everyone now):
Unfortunately, MySQL-Python 1.2.5 does not support Python 3.0+ yet (which is kinda unreasonable IMHO, Python 3+ has been out for a while). Reference : https://pypi.python.org/pypi/MySQL-python/1.2.5
So, my workaround is to use Oracle’s MySQL connector. In settings.py, change DATABASE’s ‘ENGINE’ field to:
‘ENGINE’: ‘mysql.connector.django’,
More info could be found in the last paragraph of the first answer to this question: Setting Django up to use MySQL
Hope this helps!!
- [Django]-Django template can't see CSS files
- [Django]-How to remove all of the data in a table using Django
- [Django]-Using window functions in an update statement
3
I have a slightly different setup, but think my solution will help you out.
I have a Windows 8 Machine, Python 2.7 installed and running my stuff through eclipse.
Some Background:
When I did an easy install
it tries to install MySQL-python 1.2.5
which failed with an error: Unable to find vcvarsall.bat
. I did an easy_install
of pip
and tried the pip
install which also failed with a similar error. They both reference vcvarsall.bat
which is something to do with visual studio, since I don’t have visual studio on my machine, it left me looking for a different solution, which I share below.
The Solution:
- Reinstall python 2.7.8 from 2.7.8 from https://www.python.org/download this will add any missing registry settings, which is required by the next install.
- Install 1.2.4 from http://pypi.python.org/pypi/MySQL-python/1.2.4
After I did both of those installs I was able to query my MySQL db through eclipse.
- [Django]-HTML – How to do a Confirmation popup to a Submit button and then send the request?
- [Django]-Django static annotation
- [Django]-Django Password Generator
1
MySqldb python install windows
MySQL-python 1.2.3 for Windows and Python 2.7, 32bit and 64bit versions
- [Django]-How to implement followers/following in Django
- [Django]-Difference between auto_now and auto_now_add
- [Django]-Request.user returns a SimpleLazyObject, how do I "wake" it?
0
If you encounter the problem with missing MS VC 14 Build tools while trying pip install mysqlclient
a possible solution for this may be https://stackoverflow.com/a/51811349/1552410
- [Django]-Django models: default value for column
- [Django]-Access web server on VirtualBox/Vagrant machine from host browser?
- [Django]-Django rest framework: query parameters in detail_route
0
Just Download mysqlclient from here https://www.lfd.uci.edu/~gohlke/pythonlibs/
be careful while downloading the right version depending on your your python version installed.
Then proceed with the import.
It worked for me because in my case the error was telling to install Visual Studio C++ 14.0 something which wasted my time and occupied around 10GB of space in my C drive.
So recommending installing mysqlclient using pip install mysqlclient
- [Django]-How to merge consecutive database migrations in django 1.9+?
- [Django]-Custom validation in Django admin
- [Django]-How do I output HTML in a message in the new Django messages framework?
0
For phpmydamin you can use following step
-
Go to python install path like
cd C:\Users\Enamul\AppData\Local\Programs\Python\Python37-32\Scripts
-
Run the command
pip install PyMySQL
-
In the python shell import library like
import pymysql
-
connection to databasbe
db = pymysql.connect(host='localhost',user='root',passwd='yourpassword', database="bd")
-
get cursor
cursor = db.cursor()
-
Create table like
cursor.execute("CREATE TABLE customers (name VARCHAR(255), address VARCHAR(255))")
- [Django]-Django.contrib.auth.logout in Django
- [Django]-Tailwindcss: fixed/sticky footer on the bottom
- [Django]-"No module named simple" error in Django