MySQLdb will only import for root
martinnorth
martinnorth at westnet.com.au
Sat Jul 12 04:28:25 EDT 2008
Peter Otten wrote:
> martinnorth wrote:
>
>> Hi,
>>
>> I am running Python and MySQL on Ubuntu and have installed MySQLdb. If I
>> try to import MySQLdb I get the following error:
>>
>> ActivePython 2.5.2.2 (ActiveState Software Inc.) based on
>> Python 2.5.2 (r252:60911, Mar 27 2008, 16:42:08)
>> [GCC 3.3.1 (SuSE Linux)] 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
>>
>> But if I lrun python as the root user it imports fine. Can anyone
>> suggest what might be wrong with the installation? Or is there nothing
>> wrong? I haven't seen any examples that mentioned being root to import a
>> module.
>
> You have probably installed two versions of Python. You can verify that by
> typing
>
> $ which python
>
> and
>
> $ sudo which python
>
> I suspect that root sees the python that comes with Ubuntu and that has
> MySQLdb installed while the normal user sees ActiveState's Python.
>
> Peter
>
Thanks Peter, that was it. Located the ActiveState directory and removed
it. Now the module imports for all users.
Martin
More information about the Python-list
mailing list