Hello. I managed to get Python / MySQL / MySQLdb / OS X to play nice a couple years ago, but this round I'm having difficulties.
I'm running with OS X's native Python install (though there appears to be a MacPython distro included (unimplemented?) by default in OS X 10.4 in addition to the 'standard' Python - very odd). MySQL is version 4.0.24-standard. I've edited my Apache config file to allow for .py extensions. but my python cgi scripts can't locate MySQLdb - or, more specifically, can't locate _mysql.
from the Python interpreter:
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "MySQLdb/init.py", line 27, in ?
import _mysql
ImportError: No module named _mysql
The challenge of getting python cgi scripts to work with MySQL in OS X has been a major factor in my hesitation to do further python web development (sad but true). I miss it and would love to get this working. TIA as always.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
My installation on OSX (10.4.2), Python 2.3.5, MySQL 4.1.7-standard builds and installs without errors, but the included test_MySQLdb_dbapi20.py fails in 3 tests.
The failed tests are: test_fetchall, test_fetchone and test_rowcount
Is it ok to fail these?
Here is the testlog:
laavu-zapto-org:~/Desktop/MySQL-python-1.2.1c3 Petri$ python test_MySQLdb_dbapi20.py
.......................F.F....F....
======================================================================
FAIL: test_fetchall (main.test_MySQLdb)
Traceback (most recent call last):
File "/Users/Petri/Desktop/MySQL-python-1.2.1c3/dbapi20.py", line 634, in test_fetchall
self.assertRaises(self.driver.Error,cur.fetchall)
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/unittest.py", line 295, in failUnlessRaises
raise self.failureException, excName
AssertionError: Error
Traceback (most recent call last):
File "/Users/Petri/Desktop/MySQL-python-1.2.1c3/dbapi20.py", line 304, in test_rowcount
'cursor.rowcount should be -1 after executing no-result '
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/unittest.py", line 302, in failUnlessEqual
raise self.failureException, \
AssertionError: cursor.rowcount should be -1 after executing no-result statements
Ran 35 tests in 0.916s
FAILED (failures=3)
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You can safely ignore those errors. The author of that test suite has taken an excessively narrow and unreasonable (IMO) interpretation of the API specification.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello. I managed to get Python / MySQL / MySQLdb / OS X to play nice a couple years ago, but this round I'm having difficulties.
I'm running with OS X's native Python install (though there appears to be a MacPython distro included (unimplemented?) by default in OS X 10.4 in addition to the 'standard' Python - very odd). MySQL is version 4.0.24-standard. I've edited my Apache config file to allow for .py extensions. but my python cgi scripts can't locate MySQLdb - or, more specifically, can't locate _mysql.
from the Python interpreter:
>>> import MySQLdb
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "MySQLdb/init.py", line 27, in ?
import _mysql
ImportError: No module named _mysql
The challenge of getting python cgi scripts to work with MySQL in OS X has been a major factor in my hesitation to do further python web development (sad but true). I miss it and would love to get this working. TIA as always.
What version of MySQLdb did you install? Try the latest 1.2.1 release candidate.
currently 1.2.0 - I'll try the 1.2.1 release and keep you posted!
brilliant! That was totally painless!
I am trying to install MySQLdb version 1.2.1c3.
My installation on OSX (10.4.2), Python 2.3.5, MySQL 4.1.7-standard builds and installs without errors, but the included test_MySQLdb_dbapi20.py fails in 3 tests.
The failed tests are: test_fetchall, test_fetchone and test_rowcount
Is it ok to fail these?
Here is the testlog:
laavu-zapto-org:~/Desktop/MySQL-python-1.2.1c3 Petri$ python test_MySQLdb_dbapi20.py
.......................F.F....F....
======================================================================
FAIL: test_fetchall (main.test_MySQLdb)
Traceback (most recent call last):
File "/Users/Petri/Desktop/MySQL-python-1.2.1c3/dbapi20.py", line 634, in test_fetchall
self.assertRaises(self.driver.Error,cur.fetchall)
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/unittest.py", line 295, in failUnlessRaises
raise self.failureException, excName
AssertionError: Error
======================================================================
FAIL: test_fetchone (main.test_MySQLdb)
Traceback (most recent call last):
File "/Users/Petri/Desktop/MySQL-python-1.2.1c3/dbapi20.py", line 487, in test_fetchone
self.assertRaises(self.driver.Error,cur.fetchone)
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/unittest.py", line 295, in failUnlessRaises
raise self.failureException, excName
AssertionError: Error
======================================================================
FAIL: test_rowcount (main.test_MySQLdb)
Traceback (most recent call last):
File "/Users/Petri/Desktop/MySQL-python-1.2.1c3/dbapi20.py", line 304, in test_rowcount
'cursor.rowcount should be -1 after executing no-result '
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/unittest.py", line 302, in failUnlessEqual
raise self.failureException, \ AssertionError: cursor.rowcount should be -1 after executing no-result statements
Ran 35 tests in 0.916s
FAILED (failures=3)
You can safely ignore those errors. The author of that test suite has taken an excessively narrow and unreasonable (IMO) interpretation of the API specification.