TRying to import files from my folder not pythons lib folder
Steve Holden
steve at holdenweb.com
Fri Sep 21 14:30:10 EDT 2007
kyosohma at gmail.com wrote:
> On Sep 21, 12:32 pm, "tedpot... at gmail.com" <tedpot... at gmail.com>
> wrote:
>> Hi,
>>
>> I'm trying to create my own lib of functions, but it seems like I can
>> only import them if they are in pythons lib folder.
>>
>> Example
>> I have a folder called
>> K:\mypython
>>
>> Now in the interactive python shell I type
>> Import k:\mypython\listall
>> And get a error on :
>>
>> If I store listall.py in pythons lib folder and type
>> Limport listall
>>
>> It works fins.
>>
>> Can I create my own library of functions and store them in a separate
>> dir????
>>
>> Also I try to creat a folder in pythomns lib folder and that did not
>> work
>>
>> Help
>> -Ted
>
> One workaround is to do to this:
>
> <code>
>
> import sys
> sys.path.append(r'K:\mypython')
> import listall
>
> </code>
>
> You can also add your path to the .pth file, but I've never done that,
> so I can't tell you how.
>
> Hope that helps!
>
> Mike
>
The easiest way, particularly for testing, is to set the PYTHONPATH
variable. It should be a colon-separated list of directories on Unices,
and a semi-colon separated list on Windows. Those directories will be
added to sys.path.
See http://docs.python.org/tut/node8.html for yet more.
regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://del.icio.us/steve.holden
Sorry, the dog ate my .sigline
More information about the Python-list
mailing list