?
Solved

MySQL-python installation error

Posted on 2014-11-08
8
Medium Priority
?
363 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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 2000 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

The really strange introduction Once upon a time there were individuals who intentionally put the grass seeds to the soil with anticipation of solving their nutrition problems. Or they maybe only played with seeds and noticed what happened... Som…
Variable is a place holder or reserved memory locations to store any value. Which means whenever we create a variable, indirectly we are reserving some space in the memory. The interpreter assigns or allocates some space in the memory based on the d…
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
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…

801 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