[Pythonmac-SIG] import question

Bob Ippolito bob at redivi.com
Thu Nov 6 22:23:15 EST 2003


The name aeve is not significant.

I guess you're using Jaguar python then, my instructions were for  
Panther.. then your pth file needs to go in  
/Library/Frameworks/Python.framework/Versions/2.3/lib/python2.3/site- 
packages (I think that's right).


On Nov 6, 2003, at 10:14 PM, Scott Frankel wrote:

>
> Import works now!
>
> Sometimes it's the little things.  Like ending in ".py."  Thanks Chris!
>
> But I'm curious about your (Bob's) comments below.  Can you elaborate
> on why I should use pth files instead of environment vars to define  
> python's
> path?
>
> Also, if I switch to the pth file method, I need to ask for some  
> clarification.
> i.e.:  is the name "aeve" significant?  Does your /Library/Python/2.3
> contain Python, Resources, bin, a link to Headers, &c.?  I tried  
> creating
> a pth file with a name and path that were meaningful on my system; but
> the script couldn't find the module.  Same error as below.
>
> Thanks again!
> Scott
>
>
> On Thursday, November 6, 2003, at 11:37 AM, Bob Ippolito wrote:
>
>> On Nov 6, 2003, at 1:48 PM, Scott Frankel wrote:
>>
>>>
>>> Apologies in advance if this is so simple as to be OT ...
>>>
>>> How should I setup the PYTHONPATH var on OSX so that I can
>>> import a module I've built to another script?
>>>
>>> i.e.:
>>> I've built a module and installed it in  
>>> /usr/local/my_stuff/py_modules
>>> I've set the PYTHONPATH environment var in my  
>>> ~/Library/init/tcsh/rc.mine
>>> 	setenv PYTHONPATH /usr/local/my_stuff/py_modules
>>> Then sourced rc.mine.
>>>
>>> From my script, I get an "ImportError: no module named foo" from this
>>> 	import foo
>>> which exists and is executable in /usr/local/my_stuff/py_modules.
>>
>> IMHO, PYTHONPATH is a crutch and should rarely be used.  What you  
>> should do, for most situations, is to create "pth" files in your  
>> existing sys.path .. for example, in my /Library/Python/2.3, I have a  
>> file aeve.pth which contains (only) the following text  
>> "/Users/bob/svn.undefined.org/aeve" sans quotes.  What this means, is  
>> when the python interpreter starts (if it finds site.py, of course,  
>> which is almost all the time) it will add  
>> /Users/bob/svn.undefined.org/aeve to sys.path and find any  
>> modules/packages in that directory.
>>
>> -bob
>>
>
>
> _______________________________________________
> Pythonmac-SIG maillist  -  Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig




More information about the Pythonmac-SIG mailing list