Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Re: MySQLdb will only import for root (http://www.velocityreviews.com/forums/t625071-re-mysqldb-will-only-import-for-root.html)

Diez B. Roggisch 07-11-2008 11:12 AM

Re: MySQLdb will only import for root
 
martinnorth schrieb:
> 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.


Try importing sys and printing out sys.path both with a "normal" account
and the root-account, to see if there are any differences. And of course
make sure both actually use the same interpreter.

Beyond that, you are right: there is no root-only-importing.

Diez

Jeff 07-11-2008 11:36 AM

Re: MySQLdb will only import for root
 
Is it possible the module was installed with priviledges set too
strict? Perhaps the interpreter cannot see the module when it is run
from a normal user account.

Diez B. Roggisch 07-11-2008 11:59 AM

Re: MySQLdb will only import for root
 
Jeff schrieb:
> Is it possible the module was installed with priviledges set too
> strict? Perhaps the interpreter cannot see the module when it is run
> from a normal user account.


Possible - certainly. Yet unrealistic, because usually root access is
*required* to system-wide install a package - thus the normal install
processes ensure proper rights.

Diez

Peter Otten 07-12-2008 06:24 AM

Re: MySQLdb will only import for root
 
martinnorth wrote:

> Diez B. Roggisch wrote:
>> martinnorth schrieb:
>>> 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.

>>
>> Try importing sys and printing out sys.path both with a "normal" account
>> and the root-account, to see if there are any differences. And of course
>> make sure both actually use the same interpreter.
>>
>> Beyond that, you are right: there is no root-only-importing.
>>
>> Diez

>
> Now that I look at, it appears it might not be the same interpreter.
> When running python as root I get:
>
> Python 2.5.2 (r252:60911, Apr 21 2008, 11:12:42)
> [GCC 4.2.3 (Ubuntu 4.2.3-2ubuntu7)] on linux2
> Type "help", "copyright", "credits" or "license" for more information.
>
> Which is completely different from when I'm a normal user (see original
> post). And yes, sys.path is different.
>
> Being somewhat new to python and linux, how would I go about fixing
> this? How do I get a normal user to run the same interpreter? Is it to
> do with my PATH?


Yes, you can either invoke the standard interpreter explicitly with

$ /usr/bin/python

or remove /the/path/to/activestate/python

from your PATH. (If you were just experimenting and don't really need
ActiveState I recommend that you remove it completely)

Peter



All times are GMT. The time now is 06:46 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.