Solved

MySQL-python installation error

Posted on 2014-11-08
8
336 Views
Last Modified: 2014-11-13
I am ready to install Django.  MY-SQL-Python is a prerequisit for mySQL connection to Python.  I ran
pip install mysql-python

Open in new window


and ran into the following error (in fact there were other errors before this last one, but found that the version of MS Visual C++ was not compatible with Python. Problem was corrected after installing MS Visual C++ 10)

Attached is the pip.log.  What should I do to fix this error?
pip.log
0
Comment
Question by:cpeters5
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
8 Comments
 
LVL 25

Expert Comment

by:clockwatcher
ID: 40430310
MySQL-python doesn't have a python 3 version available.  So don't think you are going to be able to get it installed under python 3 which appears to be what you are running.
0
 

Author Comment

by:cpeters5
ID: 40430458
clockwatcher,  
Yes, I am using python 3.3.  What are other choices for mysql-python subsitute?
0
 
LVL 25

Expert Comment

by:clockwatcher
ID: 40430846
I don't use django but a quick google and it appears that the mysql-connector (http://dev.mysql.com/downloads/connector/python/) which does have a python 3 version available will work with it:

  http://saltnlight5.blogspot.com/2014/09/django-with-python-3-and-mysql-database.html
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 

Author Comment

by:cpeters5
ID: 40431260
Thanks clockwatcher.  That is the same version I used in the installation.  I saw that it supported python v.3.  But thought there might be some undocumented problem.
0
 

Author Comment

by:cpeters5
ID: 40431281
clockwatcher and all,
What DBI and web modules  do you prefer for web-based/database application development in Python?
0
 
LVL 25

Expert Comment

by:clockwatcher
ID: 40431298
I prefer pyramid (http://www.pylonsproject.org/) for web development and SQLAlchemy (http://www.sqlalchemy.org/)  for relational databases.  

But we should be able to get django and the mysql-connector working.  I'll do a quick python 3.3 install later this morning and see how it goes.
0
 
LVL 25

Accepted Solution

by:
clockwatcher earned 500 total points
ID: 40431440
Went ahead and found a few minutes to try it out and it works fine.  Here's a walk-through from start to finish to install django under python 3.3 in a virtual environment.  I always use virtualenv for my stuff and strive to keep my base python install as clean as possible.  If you don't care about that, you can ignore the virtual environment stuff.

Installed python 3.3 (64bit)

Installed setuptools (invoke powershell and then):
  PS C:\Users> (Invoke-WebRequest https://bootstrap.pypa.io/ez_setup.py).Content | \python33\python

Install pip:
  \python33\scripts\easy_install pip

Install Python For Windows Extension/pywin32 (http://sourceforge.net/projects/pywin32) -- may not be 100% necessary but I always install this on windows.  Used to be necessary for virtualenv to work.  May not be any longer but it's a good library to have on windows anyway.

Install virtualenv:
   \python33\scripts\pip install virtualenv

Create a virtual environment for the django development:
   \python33\scripts\virtualenv mydjangoapp

Change directory to the newly created virtualenv:
   cd mydjangoapp

Activate the virtualenv:
   .\scripts\activate

Install django (in the virtual environment):
   pip install django

Install the mysql-connector (in the virtenv):
   pip install mysql-connector-python --allow-external mysql-connector-python

Create a django site:
   django-admin startproject mysite

Update mysite\mysite\settings.py (see http://dev.mysql.com/doc/connector-python/en/connector-python-django-backend.html for mysql-connector settings):
   'ENGINE': 'mysql.connector.django',
   'HOST':  'my.mysql.server.ip',
   'NAME': 'mydjango_db',
   'USER': 'mydjango_db_user',
   'PASSWORD': 'mydjango_db_password',
   'OPTIONS': { 'autocommit': True, }

MySQL setup:
   mysql -u root -p
   create database mydjango_db;
   create user mydjango_db_user identified by 'mydjango_db_password';
   grant all on mydjango_db.* to mydjango_db_user;
   update db set host='%' where db='mydjango_db';

Create the database (back in the virtualenv):
   python manage.py migrate

Start the server:
   python manage.py runserver

Open in new window

Everything worked fine.  I'm guessing the problem that you may have run into was that you were trying to use the MySQLDb django engine.  You need to make sure that you're using the engine appropriate to the connector that you're using.  Under python 3, you need to use the mysql-connector and the engine for that is mysql.connector.django (http://dev.mysql.com/doc/connector-python/en/connector-python-django-backend.html).  So you need to make sure you update the ENGINE setting in the settings.py file.
0
 

Author Closing Comment

by:cpeters5
ID: 40440971
clockwatcher,
Thank you for the clear instruction.  I was out of the loop for a few days.  Just tried your approach and able to install django in virtual env without error!  I will close this question but will continue to post new questions as I learn the art of web dev in python!  
pax
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction On September 29, 2012, the Python 3.3.0 was released; nothing extremely unexpected,  yet another, better version of Python. But, if you work in Microsoft Windows, you should notice that the Python Launcher for Windows was introduced wi…
Sequence is something that used to store data in it in very simple words. Let us just create a list first. To create a list first of all we need to give a name to our list which I have taken as “COURSE” followed by equals sign and finally enclosed …
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question