I need to connect MySQLdb - module.
I download MySQLdb - module and install it.
But when i write (in python interactive shell): import MySQLdb - i get no module named MySQLdb.
Then i decided to include MySQLdb directory in PYTHONPATH variable.
I write (in python interactive shell):
export PYTHONPATH=${PYTHONPATH}:/where/module/lives/
And in response i receive a syntax error: invalid syntax: export PYTHONPATH^=${PYTHONPATH}:/where/module/lives/
What's wrong with syntax here?
If you really mean you are typing
>>> export PYTHONPATH...
in the Python "interactive shell", the syntax error is because it is not valid Python, it is a command (bash) shell statement:
$ export PYTHONPATH="$PYTHONPATH:/where/module/lives/"
$ python
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
>>> import MySQLdb
>>>
If you want to modify the path to packages from within Python, you can do:
import sys
sys.path.append('/where/module/lives/')
The syntax export PYTHONPATH=… is understood by (Bourne) shells (bash, etc.).
Both uses have their advantage:
.bashrc, etc.).If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With