Using mysql in conjuntion with Sage?

i like this post (click again to cancel)
2
i dont like this post (click again to cancel)

Hello,

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.

/home/johndoe/Sage/local/bin
/home/johndoe/Sage/local/lib/python2.6/site-packages/setuptools-0.6c9-py2.6.egg
/home/johndoe/Sage/local/lib/python2.6/site-packages/Twisted-9.0.0-py2.6-linux-i686.egg
/home/johndoe/Sage/local/lib/python2.6/site-packages/zope.interface-3.6.1-py2.6-linux-i686.egg
/home/johndoe/Sage/local/lib/python2.6/site-packages/zope.proxy-3.6.0-py2.6-linux-i686.egg
/home/johndoe/Sage/local/lib/python2.6/site-packages/zope.exceptions-3.6.1-py2.6.egg
/home/johndoe/Sage/local/lib/python2.6/site-packages/zope.testing-3.9.5-py2.6.egg
/home/johndoe/Sage/local/lib/python2.6/site-packages/ZConfig-2.8.0-py2.6.egg
/home/johndoe/Sage/local/lib/python2.6/site-packages/zdaemon-2.0.4-py2.6.egg
/home/johndoe/Sage/local/lib/python2.6/site-packages/ZODB3-3.7.0-py2.6-linux-i686.egg
/home/johndoe/Sage/local/lib/python2.6/site-packages/Pygments-1.3.1-py2.6.egg
/home/johndoe/Sage/local/lib/python2.6/site-packages/Jinja2-2.5.5-py2.6.egg
/home/johndoe/Sage/local/lib/python2.6/site-packages/Sphinx-1.0.4-py2.6.egg
/home/johndoe/Sage/local/lib/python2.6/site-packages/SQLAlchemy-0.5.8-py2.6.egg
/home/johndoe/Sage/devel/sagenb
/home/johndoe/Sage/local/bin
/home/johndoe/Sage/local/lib/python
/home/johndoe/Sage/local/lib/python26.zip
/home/johndoe/Sage/local/lib/python2.6/plat-linux2
/home/johndoe/Sage/local/lib/python2.6/lib-tk
/home/johndoe/Sage/local/lib/python2.6/lib-old
/home/johndoe/Sage/local/lib/python2.6/lib-dynload
/home/johndoe/Sage/local/lib/python2.6/site-packages
/home/johndoe/Sage/local/lib/python2.6/site-packages/PIL
/home/johndoe/Sage/local/lib/python2.6/site-packages/IPython/Extensions
/home/johndoe/.sage/ipython

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 use the programming power of python, and the mathematical power of sage together, to analyze data stored in a mysql database.

Thanks, William

asked Jan 30 '11

William Smythe gravatar image William Smythe
21 1 1 3

2 Answers:

i like this answer (click again to cancel)
1
i dont like this answer (click again to cancel)

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 http://sourceforge.net/projects/mysql-python/. 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 setup.py install

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

link

posted Jan 30 '11

bryanward gravatar image bryanward
11 1
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

I downloaded http://sourceforge.net/projects/mysql-python/ and extracted the file. I then pasted the MySQL folder inside of my Sage folder. Then in Sage I typed "sudo sage setup.py 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
Chapter3_2.py  chapter5_1.py  devel     ipython   MySQL-python-1.2.3  sage-README-osx.txt  VERSION.txt
Chapter3.py    COPYING.txt    examples  local     README.txt          spkg
chapter4_1.py  data           Hello.py  Makefile  sage                sudoku?
johndoe@johndoe:~/Sage$

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

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

What am I doing wrong?

Thanks, William

link

posted Jan 30 '11

William Smythe gravatar image William Smythe
21 1 1 3

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
Login/Signup to Post

Question tools

Tags:

Stats:

Asked: Jan 30 '11

Seen: 515 times

Last updated: Jan 30 '11

powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.