Re: Module not found in script that was found in command-lineinterpreter. Possible Path issue?

Discussion in 'Python' started by Jacob Davis, Apr 15, 2008.

  1. Jacob Davis

    Jacob Davis Guest

    On Apr 3, 2008, at 10:54 AM, Trent Mick wrote:
    > Jacob Davis wrote:
    >> I just installed the MySQLdb module and I have been able to get it
    >> to run in my command line interpreter. I am running Mac Leopard,
    >> and Python 2.5.
    >> I have tested importing and actually connecting and using a MySQL
    >> database, although it issues some warning:
    >> SnakeBite:MySQL-python-1.2.2 Snake$ python
    >> Python 2.5 (r25:51918, Sep 19 2006, 08:49:13) [GCC 4.0.1 (Apple
    >> Computer, Inc. build 5341)] on darwin
    >> Type "help", "copyright", "credits" or "license" for more
    >> information.
    >>>>> import MySQLdb

    >> /Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
    >> site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-fat.egg/
    >> UserWarning: Module _mysql was already imported from

    > From that message it looks like this "python" is /usr/local/bin/
    > python (i.e. a separate installation than Apple's system python at /
    > usr/bin/python and /System/Library/Frameworks/Python.framework).
    > You can tell for sure by doing:
    > $ which python
    >> However, while writing a .py script (with Komodo Edit) I try to
    >> simply import the module and the in-Komodo interpreter returns an
    >> error:
    >> Traceback (most recent call last):
    >> File "/Users/Snake/Documents/NPS/Thesis/Source_Code/Genetics/
    >>", line 11, in <module>
    >> import MySQLdb
    >> ImportError: No module named MySQLdb

    > I suspect that this is because your run of Komodo Edit doesn't have
    > "/usr/local/bin" on its PATH and is using "/usr/bin/python" instead
    > of the one you typically use on the command line.
    > You can configure Komodo to know about /usr/local/bin by adding a
    > "PATH" setting in the "Environment" prefs panel. Arguably Komodo
    > should just add /usr/local/bin to its runtime PATH by default, but
    > unfortunately it currently doesn't. Komodo doesn't pick up your
    > normal bash shell environment because of problems trying to get that
    > information in general.
    > Please let me know (or on the komodo-discuss list [^1] or Komodo bug
    > database [^2]) if you have any problems getting that going.
    > Cheers,
    > Trent
    > [1]:
    > [2]:
    > --
    > Trent Mick
    > trentm at

    Thanks, that seems to have worked. I added "/usr/local/bin" to the
    PATH in the preferences Environment panel in Komodo. Then in
    preferences I went into the Python pane and changed my selected
    interpreter from "/usr/bin/pythonw" to the now available "/usr/local/

    Thanks again,

    Jacob Davis, Apr 15, 2008
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ron Adam
    Ron Adam
    Aug 2, 2005
  2. Maric Michaud
    Maric Michaud
    Jun 24, 2006
  3. Trent Mick
    Trent Mick
    Apr 3, 2008
  4. Stéphane Klein
    Stéphane Klein
    Jul 5, 2011
  5. Mr. Nonsense

    Require a module, but not fail if not found

    Mr. Nonsense, Jul 20, 2009, in forum: Perl Misc
    Mr. Nonsense
    Jul 20, 2009

Share This Page