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.
Martin 8 3342
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
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.
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
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
Diez B. Roggisch wrote:
>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.
According to the OP, it is root that *does* have access to MySQLdb and a
normal user that does not. It is a very realistic possibility to install
something as root to which normal users do not have access. Installation
scripts that assume a particular umask during install, for example, are
especial culprits.
I have noticed this problem myself with python modules that include compiled
C extensions, as MySQLdb does. However, in the case where the extension
module itself has incorrect permissions, the error would point to a missing
_mysql, rather than a missing MySQLdb.
Jeffrey
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?
Martin
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
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Dave Harrison |
last post by:
Hi all, got a problem combinging mx and MySQLdb, when I build and install both for my Python2.1 install on a Solaris 9 box I can import mx fine, but importing MySQLdb causing python to core dump.
...
|
by: Tim Williams |
last post by:
I'm trying to write a simple python program to access a MySQL
database. I'm having a problem with using MySQLdb to get the results
of a SQL command in a cursor. Sometimes the cursor.execute works,...
|
by: John Fabiani |
last post by:
Hi,
I'm a newbie and I'm attempting to learn howto create a select statement.
When I use
>>> string1='18 Tadlock Place'
>>> cursor.execute("SELECT * FROM mytest where address = %s",string1)
All...
|
by: ws Wang |
last post by:
MySQLdb is working fine at command line, however when I tried to use
it with mod_python, it give me a "server not initialized" error.
This is working fine:
----------------------- testmy.py...
|
by: Mondal |
last post by:
Hi,
I am using MySQL 5.0 beta and Active Python 2.4. I have the correct
version of MySQLdb installed. The problem is that I can't connect to
MySQL through the Active Python interactive window.
...
|
by: Grzegorz Smith |
last post by:
Hi all. I'm trying get data from text field in MySQl 5.0 with my National
characters. Data are stored in utf8 encodings. Here is the script:
import MySQLdb, MySQLdb.cursors
conn =...
|
by: antonyliu2002 |
last post by:
I downloaded MySQL-python-1.2.1 from SourceForge and installed it on a
Mandrake system (Mandrake Linux 9.2 3.3.1-2mdk on linux2).
The installation was successful. The gcc version is 3.3.
My...
|
by: rhitam30111985 |
last post by:
hi all .. consider the following code: i basically need to build a table in the mysql database with two fields , country and office list...
import MySQLdb
import sys
import os
...
|
by: Steve Holden |
last post by:
Vaibhav.bhawsar wrote:
imported
The point here is that MySQLdb is a package, not a module. Some packages
have their top-level __init__.py import the package's sub-modules or
sub-packages to...
|
by: antdb |
last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine
In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
|
by: Matthew3360 |
last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function.
Here is my code.
header("Location:".$urlback);
Is this the right layout the...
|
by: AndyPSV |
last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
|
by: Arjunsri |
last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
|
by: WisdomUfot |
last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
|
by: Matthew3360 |
last post by:
Hi,
I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
|
by: Oralloy |
last post by:
Hello Folks,
I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA.
My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
|
by: BLUEPANDA |
last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
|
by: Ricardo de Mila |
last post by:
Dear people, good afternoon...
I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control.
Than I need to discover what...
| |