Re: [Tutor] newbie OSX module path question

2005-02-14 Thread Danny Yoo


On Mon, 14 Feb 2005, Mike Hall wrote:

 I'm on OS X, and I cannot get Python to import modules I've saved. I
 have created the the environment.plist file and appended it with my
 desired module path. If I print sys.path from the interpreter, my new
 path does indeed show up as the first listing,


Hi Mike,

Can you show us what your sys.path looks like?  Just do a cut-and-paste so
we can quickly validate it for you.

 yet any attempt at importing modules from this directory fails with
 ImportError.

Can you show us the exact thing you're typing, as well as the literal
error that Python shows?  I don't mean to be suspicious, but we have to
check for silly things like case-sensitivity issues.  I know that Mac OS
X's file system is case insensitive, so this might not be such a big
issue, but I'd still like looking at literal error messages.


Otherwise, I'm at a loss: the import should work.  I think we'll need to
see some more before we can diagnose this.  Do you have problems doing an
import if your modules's directory is the current working directory?

Also, can you do a quick 'ls -l' on your module directory?  That'll help
us just a quick double-check on what the files look like.

Best of wishes to you!

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] newbie OSX module path question

2005-02-14 Thread Mike Hall
Hm, so if I import glob, and then execute this line:
print glob.glob('/Local_HD/Users/mike/Documents/pythonModules/*.py')
I simply get brackets returned:
[]
...not sure what this means. Thanks again.


On Feb 14, 2005, at 5:41 PM, Danny Yoo wrote:

On Mon, 14 Feb 2005, Mike Hall wrote:
Can you show us what your sys.path looks like?  Just do a
cut-and-paste so we can quickly validate it for you.
Thanks for the response. Here's a paste of what sys.path returns. The
first listing is the path inside of environment.plist:
['', '/Local_HD/Users/mike/Documents/pythonModules',
'/Users/tempmike/Documents/pythonModules',
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python23.zip',
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3',
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/plat-darwin',
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/plat-mac',
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/plat-mac/lib-scriptpackages',
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/lib-tk',
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/lib-dynload',
'/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages']
Can you show us the exact thing you're typing, as well as the literal
error that Python shows?
I will attempt to import using 'import' followed by file name. 
Example:

import module1
The error returned will be:
ImportError: No module named module1

[Meta: Please keep python-tutor in CC, so that all of us on the mailing
list can help you.]
Hi Mike,
Ok, can you do this at the Python prompt?
###
import glob
print glob.glob('/Local_HD/Users/mike/Documents/pythonModules/*.py')
###
Copy and paste the output you see.
If things go wrong, then we will have a good focus point to debug the
problem.  But if things go right --- if you see a bunch of Python 
module
files --- then I will be stuck and will have to think of something 
else.
*grin*


Do you have problems doing an import if your modules's directory is
the current working directory?
Funny you should mention that. After posting to this list, I tried
cd'ing over to the dir I created for modules, and then launched 
Python.
My modules can indeed be imported using this method.  But I'm still
curious as to why I cannot get a successful import (when I'm not 
within
my work dir) when the path is visibly defined within the sys.path
variable? Thanks very much.
Ok, so there appears to be nothing wrong with the modules themselves or
with importing them when they're in the current working directory. We
should then focus on sys.path itself, since that's the mechanism Python
uses to lookup modules that aren't in the current directory.
For the moment, I'll assume that there's something funky with the
pathname.  As mentioned earlier, it could be as subtle as a
case-sensitivity issue.  The glob statement above will help us check to
see if Python can see those files, at least.
Best of wishes to you!
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] newbie OSX module path question

2005-02-14 Thread Mike Hall
Ok, I've got it working. The environment.plist file wants a path 
beginning with /Users, not /Local_HD. So simple!  Thanks everyone.

On Feb 14, 2005, at 6:26 PM, David Rock wrote:
* Mike Hall [EMAIL PROTECTED] [2005-02-14 18:22]:
Hm, so if I import glob, and then execute this line:
print glob.glob('/Local_HD/Users/mike/Documents/pythonModules/*.py')
I simply get brackets returned:
[]
...not sure what this means. Thanks again.
It means it didn't find anything that matches that pattern, which
suggests that the directory does not contain *.py files. That might be 
a
problem. ;-)

--
David Rock
[EMAIL PROTECTED]
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] newbie OSX module path question

2005-02-14 Thread Max Noel
On Feb 15, 2005, at 02:38, Mike Hall wrote:
Ok, I've got it working. The environment.plist file wants a path 
beginning with /Users, not /Local_HD. So simple!  Thanks everyone.
	Yeah, the system hard drive on Mac OS X (which is seen as Macintosh 
HD, or in your case Local HD in the Finder) is mounted as the root 
of the filesystem. IOW, it's referred to as /, not /Macintosh HD.

-- Max
maxnoel_fr at yahoo dot fr -- ICQ #85274019
Look at you hacker... A pathetic creature of meat and bone, panting 
and sweating as you run through my corridors... How can you challenge a 
perfect, immortal machine?

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor