Ask Your Question

Using mysql in conjuntion with Sage?

asked 2011-01-30 01:30:41 +0200

William Smythe gravatar image


I'm using Ubuntu (new to it), and am really excited about Sage. I can't afford Matlab. I would like to interface Sage/Python with MySql. I've already installed MySql according to this link.

I tried the command import MySQLdb, but it didn't work. The output from my terminal is pasted below.

johndoe@johndoe:~$ python Python 2.6.6 (r266:84292, Sep 15 2010, 15:52:39) [GCC 4.4.5] on linux2 Type "help", "copyright", "credits" or "license" for more information.

import MySQLdb Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named MySQLdb quit Use quit() or Ctrl-D (i.e. EOF) to exit quit() johndoe@johndoe:~$ cd ~/Sage johndoe@johndoe:~/Sage$ ./sage ---------------------------------------------------------------------- | Sage Version 4.6.1, Release Date: 2011-01-11 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- sage: import MySQLdb --------------------------------------------------------------------------- ImportError
Traceback (most recent call last)

/home/johndoe/Sage/<ipython console=""> in <module>()

ImportError: No module named MySQLdb sage: sage:

I believe I have the same problem as discussed here

However, I'm so new to Ubuntu, that I don't quite follow. I followed the instructions and ran

import sys
for path in sys.path:
     print path

I then received the output pasted below.


However, I don't understand how to use this information to update the PYTHONPATH environment variable or the library path.

Can anyone help? My basic dilemma is how to ... (more)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2011-01-30 13:04:43 +0200

bryanward gravatar image

The easiest thing for you may be install MySQL within the SAGE environment. This can be done by downloading the MySQL library for python from Then extract it using your favorite GUI tools, or simply:

tar xzvf MySQL*.tar.gz

from wherever you download it to. Then you can install it to your SAGE environment with something as simple as:

sudo sage install

You can then delete all the MySQL-python related files in your downloads directory; they have been installed in your SAGE path.

edit flag offensive delete link more

answered 2011-01-30 16:22:55 +0200

William Smythe gravatar image

I downloaded and extracted the file. I then pasted the MySQL folder inside of my Sage folder. Then in Sage I typed "sudo sage install", but it didn't work. The terminal gave me the output below. This shows that MySQL-python-1.2.3 is now located in my Sage folder.

johndoe@johndoe:~/Sage$ ls  devel     ipython   MySQL-python-1.2.3  sage-README-osx.txt  VERSION.txt    COPYING.txt    examples  local     README.txt          spkg  data   Makefile  sage                sudoku?

Then I started Sage and entered "sudo sage install". The output from this is below.

johndoe@johndoe:~/Sage$ sudo sage install
sudo: sage: command not found

What am I doing wrong?

Thanks, William

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2011-01-30 01:30:41 +0200

Seen: 1,372 times

Last updated: Jan 30 '11