[PythonCE] Can't Get My Import Module Command to Work Properly

Luke Dunstan coder_infidel at hotmail.com
Wed May 17 14:02:58 CEST 2006

Or even easier:

"The most convenient way is to add a path configuration file to a directory 
that's already on Python's path, usually to the .../site-packages/ 
directory. Path configuration files have an extension of .pth, and each line 
must contain a single path that will be appended to sys.path. (Because the 
new paths are appended to sys.path, modules in the added directories will 
not override standard modules. This means you can't use this mechanism for 
installing fixed versions of standard modules.)"

(from the Python manual)

For example, I have a file "sdcard.pth" in \Program Files\Python24 
containing a single line:

\sd-mmc Card\python


----- Original Message ----- 
From: "Mark Doukidis" <mdoukidis at gmail.com>
To: "Bandung" <bandung at skyesystems.com>
Cc: <pythonce at python.org>
Sent: Wednesday, May 17, 2006 9:15 AM
Subject: Re: [PythonCE] Can't Get My Import Module Command to Work Properly

> Try using "sitecustomize.py". This is the setup I used for Python2.3:
> # sitecustomize.py to be placed in python library directory.
> import os
> import sys
> if os.name == 'ce':
>  sys.path.append("\My Documents\Personal")
> Hope this is useful.
> Mark Doukidis
> On 5/17/06, Bandung <bandung at skyesystems.com> wrote:
>> Using the PythonCE interactive window, I am trying to shortcut having to 
>> type
>> in a sys.path.append() command every time I want to run a python script 
>> that
>> is not in the standard path.  So I created a module called paths.py with
>> several sys.path.append commands in it.
>> When I import this module into the interpreter, the interpreter appears 
>> to
>> accept it with no errors.  However, I can't run any python scripts that 
>> are
>> within the new paths that my append() commands define.
>> If I fire up a python shell interpretor and type these two commands - the
>> sys.path.append() command and then type another command line like ... 
>> from
>> "new_module" import * this works.  But if I put them in a module called
>> "paths" and import that module into my interpreter session, it doesn't 
>> work.
>> Why?
>> (1. This doesn't work)
>> >>>import paths
>> The paths.py file is sitting in the Python24\Lib  directory and contains 
>> the
>> following,
>> -------
>> #paths.py
>> # append this path to system path
>> import sys
>> sys.path.append("\My Documents\Personal")
>> from calctaxes import *
>> No such module "calctaxes" error results.
>> ------
>> The use of any functions within calctaxes fails even though the file
>> calctaxes.py sits in the directory \My Documents\Personal
>> (2. But this works if I type the following into the interpreter...
>> >>>import sys
>> >>>sys.path.append("\My Documents\Personal")
>> >>>from calctaxes import *
>> Then all of my functions within calctaxes work from the interpreter.
>> --
>> View this message in context: 
>> http://www.nabble.com/Can%27t-Get-My-Import-Module-Command-to-Work-Properly-t1631521.html#a4419614
>> Sent from the Python - pythonce forum at Nabble.com.
>> _______________________________________________
>> PythonCE mailing list
>> PythonCE at python.org
>> http://mail.python.org/mailman/listinfo/pythonce
> _______________________________________________
> PythonCE mailing list
> PythonCE at python.org
> http://mail.python.org/mailman/listinfo/pythonce

More information about the PythonCE mailing list