Doing the basic tutorial, MySQL-python problems.

147 views
Skip to first unread message

Jimmy Pants

unread,
Oct 16, 2013, 4:10:34 PM10/16/13
to django...@googlegroups.com
I'm trying to do the "Writing Your first Django App" tutorial, and Django can't see MySQL-python, though it is installed globally.

I'm not sure if this is a virtualenv problem or what.



Outside of virtualenv:

jimmy@lilly ~/mysite $ sudo pip install MySQL-python
[sudo] password for jimmy:
Requirement already satisfied (use --upgrade to upgrade): MySQL-python in /usr/lib/python2.7/dist-packages
Cleaning up...

*In* my Django virtualenv:

(DJANGO)jimmy@lilly ~/mysite $ pip install MySQL-python
Downloading/unpacking MySQL-python
  Downloading MySQL-python-1.2.4.zip (113kB): 113kB downloaded
  Running setup.py egg_info for package MySQL-python
    Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz
    Extracting in /tmp/tmpLPLYIS
    Now working in /tmp/tmpLPLYIS/distribute-0.6.28
    Building a Distribute egg in /home/jimmy/.virtualenvs/DJANGO/build/MySQL-python
    /home/jimmy/.virtualenvs/DJANGO/build/MySQL-python/distribute-0.6.28-py2.7.egg
    sh: 1: mysql_config: not found
    Traceback (most recent call last):
      File "<string>", line 16, in <module>
      File "/home/jimmy/.virtualenvs/DJANGO/build/MySQL-python/setup.py", line 18, in <module>
        metadata, options = get_config()
      File "setup_posix.py", line 43, in get_config
        libs = mysql_config("libs_r")
      File "setup_posix.py", line 25, in mysql_config
        raise EnvironmentError("%s not found" % (mysql_config.path,))
    EnvironmentError: mysql_config not found
    Complete output from command python setup.py egg_info:
    Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.28.tar.gz

Extracting in /tmp/tmpLPLYIS

Now working in /tmp/tmpLPLYIS/distribute-0.6.28

Building a Distribute egg in /home/jimmy/.virtualenvs/DJANGO/build/MySQL-python

/home/jimmy/.virtualenvs/DJANGO/build/MySQL-python/distribute-0.6.28-py2.7.egg

sh: 1: mysql_config: not found

Traceback (most recent call last):

  File "<string>", line 16, in <module>

  File "/home/jimmy/.virtualenvs/DJANGO/build/MySQL-python/setup.py", line 18, in <module>

    metadata, options = get_config()

  File "setup_posix.py", line 43, in get_config

    libs = mysql_config("libs_r")

  File "setup_posix.py", line 25, in mysql_config

    raise EnvironmentError("%s not found" % (mysql_config.path,))

EnvironmentError: mysql_config not found

----------------------------------------
Cleaning up...
Command python setup.py egg_info failed with error code 1 in /home/jimmy/.virtualenvs/DJANGO/build/MySQL-python
Storing complete log in /home/jimmy/.pip/pip.log


Bill Freeman

unread,
Oct 16, 2013, 4:22:37 PM10/16/13
to django-users
If the program mysql_config is installed on your box, it may be installed in a directory that is not on your path.  If you can find it on your box (try the locate and find commands), you can add the directory to your PATH by hand before running pip (or easy_install).  It only needs to be there for the runnings of pip that instiall or update MySQL-python so you don't need to add the directory permanently.  (An alternative is a symbolic link to it in some directory that is on your path, such as maybe /usr/local/bin - though this is slightly less certain to work, depending on how clever mysql_config is - I don't use MySQL, so I don't know for sure.)


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2679ff82-df1c-403a-89f1-f6e1f62f6a84%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

J. Paskaruk

unread,
Oct 16, 2013, 4:32:34 PM10/16/13
to django...@googlegroups.com
I ran:

sudo find / -name 'mysql_config'

and it didn't find it. Using the same search, I did find something from my home dir, so it seems that it's not actually installed, or rather.. argh. I've attempted every "this is how to install MySQL-python method I could find on the web, and it either fails to install or says it's already installed, but the damn server can't see it.

I've switched it to a sqlite database for now, but this is pissing me off...


--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/lLyFY5EIjyE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

Bill Freeman

unread,
Oct 16, 2013, 4:49:54 PM10/16/13
to django-users
If it's like PostgreSQL, it should have been installed somewhere when you installed MySQL.  But if you installed it using an O/S package manager, rather than from source, the O/S vender may have "helpfully" excluded bits they don't think you need.  Often this will require additionally installing a "-devel" (RPM based systems) or "-dev" (deb based systems) of the MySQL package.


J. Paskaruk

unread,
Oct 16, 2013, 5:45:44 PM10/16/13
to django...@googlegroups.com
I found a python-mysqldb-dbg in Synaptic, would that be it? Failing that, what would be the, umm, Pythonic way to reinstall MySQL?

I'm also confused by the various names - in Synaptic I've got python-mysqldb installed, but there's also MySQL-Python, which I can't tell if that's the same package or something entirely different... I'm drowning in new software and concepts at the moment. Argh.


Bill Freeman

unread,
Oct 16, 2013, 6:01:07 PM10/16/13
to django-users
No, python-mysqldb-dbg is not related to the problem.  ("dbg" is an abbreviation for debug, while "devel" or "dev" stands for I want to do software development to work with the main package" such as building the python connectory, the operation that got you your error message.

When you pip install python-msqldb, that only installs the python connector for MySQL (and if you do it with synaptic, probably only for the system python).  You also have to install MySQL itself (with no "python-" in front of it), and it is that package that might have a -dev version.  You install MySQL and possibley MySQL-dev (or however they're spelled, I don't have a debian based system handy to check) using synaptic (or apt or dselectd or yum or rpm).  Then you do whatever you were doing (a pip install of something?) that got the original error, because it was trying to install MySQL-python (in your virtualenv, I presume).

My rule of thumb is to never install with synaptic (etc.) that which you can install with pip, but there are a bunch of things that you can't install with pip, such as MySQL itself.


J. Paskaruk

unread,
Oct 16, 2013, 6:34:51 PM10/16/13
to django...@googlegroups.com
Yah, nothing under mysql- with dev or devel. I'm getting a sort-of handle on the differences between Pip, Apt, etc, but it's all very confusing. I seem to have sqlite working, so I'm not worrying about this too much for the moment. I'm assuming that a few months from now I'll laugh at how much I'm struggling with this at the moment. :>


Robbie Scourou

unread,
Oct 16, 2013, 6:50:29 PM10/16/13
to django...@googlegroups.com
Assuming you are using ubuntu/debian:

apt-get install libmysqlclient-dev

Should give you the mysql_config tool. I *think*. I ran into similar build problems when rebuilding a server recently. I think you'll also need the python-dev package too. 

Frustration with computers is normal, just stick at it. :)

Cheers

Robbie



J. Paskaruk

unread,
Oct 16, 2013, 7:21:02 PM10/16/13
to django...@googlegroups.com

On Wed, Oct 16, 2013 at 1:50 PM, Robbie Scourou <sco...@gmail.com> wrote:
apt-get install libmysqlclient-dev


Sorry, I'm running Linux Mint, very similar to your vaporators in most respects. Can you speak Bochi? Of course I can sir, it's like a second language to me. Ok, shut up, I'll take this one.

Sorry. I exited my virtualenv to do that install first, and it did indeed install something new. Let's see... still gives the error. pip install MySQL-Python still doesn't work in the virtualenv either. Sigh.

In other news, I'm making great progress with sqlite, so if you wanna keep throwing ideas at me I'll keep trying em, but if I'm getting boring, don't worry bout it none. Like i said, as long as I'm making some kind of progress, I usually find that the stuff I find difficult today magically becomes trivial when I come back to it a few weeks later. :>

Robbie Scourou

unread,
Oct 16, 2013, 10:25:27 PM10/16/13
to django...@googlegroups.com
Shutting up sir! :)

One last thing to try:

apt-get install python-dev

Do that outside of virtualenv, then try it installing mysql-python within the virtualenv. After that, I'm out of ideas. 


--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

J. Paskaruk

unread,
Oct 16, 2013, 10:57:02 PM10/16/13
to django...@googlegroups.com
I followed your directions, and the whole thing went off without a hitch.

ARE YOU A WIZARD?!


--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/lLyFY5EIjyE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.

To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.

Robbie Scourou

unread,
Oct 17, 2013, 8:06:14 AM10/17/13
to django...@googlegroups.com
Only on weekends! Glad it's sorted for you. :)


Reply all
Reply to author
Forward
0 new messages