473,657 Members | 2,609 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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


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:MySQ L-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.framewor k/Versions/2.5/lib/python2.5/
site-packages/MySQL_python-1.2.2-py2.5-macosx-10.3-fat.egg/
_mysql.py:3: 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.framewor k).

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/
mysql_connect_ test.py", 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 "Environmen t" 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]: http://listserv.activestate.com/mail...Komodo-discuss
[2]: http://bugs.activestate.com/query.cgi?product=Komodo

--
Trent Mick
trentm at activestate.com
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/
bin/pythonw".

Thanks again,

Jake
Jun 27 '08 #1
0 979

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
1927
by: Steven | last post by:
I'm writing a Python script which can be called from the command-line, and I want to use my module doc string as the CL help text, but I don't know how to access my module object from inside the module. I've tried searching for an answer, but haven't found anything. Please excuse me if I'm missing something simple, I'm a newbie to Python. I'm doing something like this:
2
1731
by: Marcus Schneider | last post by:
I use PythonWin on WinXP. Every time I change a module, I have to leave PythonWin and re enter to make it notice I have made changes. I guess this is not the normal way to do that.. do I have to store the module at a specific place? Is there a kind of "reset" command to make the main module update specific data?
14
9387
by: DataSmash | last post by:
Hi, When I import the random module at the python interpreter, it works fine: >>> import random >>> x = random.randint(1,55) >>> print x 14 >>> BUT, when I put the same code in a python script:
3
4123
by: sir.linying | last post by:
My php script is to call perl scipt which makes use of Spreadsheet::ParseExcel module to parse Excel file. I am able to launch php script from command line so that perl script can run and properly parse Excel file. However, when I put php script on server side and then launch php through client request, perl program can't run. Anyone has any suggestion re how to fix this problem? Thanks a lot, -Ying
10
11502
by: Charles Russell | last post by:
Why does this work from the python prompt, but fail from a script? How does one make it work from a script? #! /usr/bin/python import glob # following line works from python prompt; why not in script? files=glob.glob('*.py') print files Traceback (most recent call last):
9
1226
by: noamsml | last post by:
Hi, I am new to python and am currently writing my first application. One of the problems I quickly ran into, however, is that python's imports are very different from php/C++ includes in the sense that they completely wrap the imported script in a module object. One of the problems with this was that a plugin system that I am making requires use of objects, classes and the such from the original script. Thus, on one hand, I am hesitant...
5
1538
by: Stuart D. Gathman | last post by:
The pyspf package http://cheeseshop.python.org/pypi/pyspf/] can use either pydns, or dnspython. The pyspf module has a simple driver function, DNSLookup(), that defaults to the pydns version. It can be assigned to a dnspython version, or to a test driver for in memory DNS. Or you can modify the source to "from drivermodule import DNSLookup". What is the friendliest way to make this configurable? Currently, users are modifying the...
12
1808
by: reubendb | last post by:
Hello, I am new to Python. I have the following question / problem. I have a visualization software with command-line interface (CLI), which essentially is a Python (v. 2.5) interpreter with functions added to the global namespace. I would like to keep my own functions in a separate module and then import that module to the main script (that will be executed using the CLI interpreter). The problem is, I cannot access the functions in the...
7
6227
by: Samuel A. Falvo II | last post by:
I have a shell script script.sh that launches a Java process in the background using the &-operator, like so: #!/bin/bash java ... arguments here ... & In my Python code, I want to invoke this shell script using the Subprocess module. Here is my code: def resultFromRunning_(command):
4
5808
by: vincehofmeister | last post by:
Hey everyone: I am using py2exe and everything is working fine except one module, ClientCookie, found here: http://wwwsearch.sourceforge.net/ClientCookie/ Keeps coming up as not found no matter what I do. I have tried all these combinations from the command line:
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2731
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.