By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,347 Members | 1,357 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,347 IT Pros & Developers. It's quick & easy.

Module Import Path?

P: n/a
I have just begun to learn python using o'reilly's Learning Python, and in
chapter 3 it talks about importing modules. It has me make modules to
practice using the 'import' and 'from' statements from the python command
line.

I don't know what directory to save these files in because I'm not sure what
directories 'import' is looking in to find modules. I've done some google
searches trying to find out where the 'import' search path is, but I'm not
familiar enough with python to do a clear enough search. I'd appriciate it
if anyone can help me out or point me in the right direction.
Jul 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Jesse B. said unto the world upon 31/07/2004 15:42:
I have just begun to learn python using o'reilly's Learning Python, and in
chapter 3 it talks about importing modules. It has me make modules to
practice using the 'import' and 'from' statements from the python command
line.

I don't know what directory to save these files in because I'm not sure what
directories 'import' is looking in to find modules. I've done some google
searches trying to find out where the 'import' search path is, but I'm not
familiar enough with python to do a clear enough search. I'd appriciate it
if anyone can help me out or point me in the right direction.


Hi,

import sys
sys.path

will tell you how your Python Path is configured.

On windows, you can configure your Python path by including a line like:

SET PYTHONPATH=D:\PYPATHDir1;C:\PYPATHDir2

in your Autoexec.bat file. Just be sure not to put any spaces around the
'=' and to separate multiple directories with ';' characters.

Some windows versions (not mine, so I cannot say exactly what to do) allow
you to set the PythonPath environment variable via the Control Panel.

Best,

Brian vdB
Jul 18 '05 #2

P: n/a
Jesse B. said unto the world upon 31/07/2004 15:42:
I have just begun to learn python using o'reilly's Learning Python, and in
chapter 3 it talks about importing modules. It has me make modules to
practice using the 'import' and 'from' statements from the python command
line.

I don't know what directory to save these files in because I'm not sure what
directories 'import' is looking in to find modules. I've done some google
searches trying to find out where the 'import' search path is, but I'm not
familiar enough with python to do a clear enough search. I'd appriciate it
if anyone can help me out or point me in the right direction.


Hi,

Typing too quickly, I wrote
import sys
sys.path

will tell you how your Python Path is configured.


Not everything returned by sys.path is there because of your PYTHONPATH
environment variable. For instance, the first entry is the one from which
your running script was loaded. Likewise, the standard Library Dirs are
there, too. Check out the sys module documentation for the full details.

Best,

Brian vdB

Jul 18 '05 #3

P: n/a
> I have just begun to learn python using o'reilly's Learning Python, and in
chapter 3 it talks about importing modules. It has me make modules to
practice using the 'import' and 'from' statements from the python command
line.


If you are doing the imports from the interpreter, put the modules in the
current directory. In case of a script, use the directory that the script
is in.
Jul 18 '05 #4

P: n/a
Thank you for the quick response, this was driving me alittle nuts. I
appreciate the help.
"Brian van den Broek" <bv****@po-box.mcgill.ca> wrote in message
news:ma**************************************@pyth on.org...
Jesse B. said unto the world upon 31/07/2004 15:42:
I have just begun to learn python using o'reilly's Learning Python, and in chapter 3 it talks about importing modules. It has me make modules to
practice using the 'import' and 'from' statements from the python command line.

I don't know what directory to save these files in because I'm not sure what directories 'import' is looking in to find modules. I've done some google searches trying to find out where the 'import' search path is, but I'm not familiar enough with python to do a clear enough search. I'd appriciate it if anyone can help me out or point me in the right direction.


Hi,

Typing too quickly, I wrote
import sys
sys.path

will tell you how your Python Path is configured.


Not everything returned by sys.path is there because of your PYTHONPATH
environment variable. For instance, the first entry is the one from which
your running script was loaded. Likewise, the standard Library Dirs are
there, too. Check out the sys module documentation for the full details.

Best,

Brian vdB

Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.