468,765 Members | 817 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

How to set pythonpath in Mac OS X?

Hello Pythonistas,

I am trying to get certain (self-written) libraries imported into my
scripts using statements like

"from library import function.py".

But they are not being found.

I think that the pythonpath-variable must be expanded to the location
to this libraries.

But, I can't find any usable information using Google on how to set up
the pythonpath properly.
I don't even know where to look for the pythonpath-variable?

It would be great if anyone could help me out on this?

Thanks,
Eric
Jul 18 '05 #1
2 25512
In article <ma***********************************@python.org> ,
Eric Wichterich <er*************@gmx.de> wrote:
Hello Pythonistas,

I am trying to get certain (self-written) libraries imported into my
scripts using statements like

"from library import function.py".

But they are not being found.

I think that the pythonpath-variable must be expanded to the location
to this libraries.

But, I can't find any usable information using Google on how to set up
the pythonpath properly.
I don't even know where to look for the pythonpath-variable?

It would be great if anyone could help me out on this?

Thanks,
Eric


I simply placed this in my start-up script and it works fine:

setenv PYTHONPATH /Users/Me/Documents/Python/MyModules

OS 10.2.8

J.S.
Jul 18 '05 #2
In article <ma***********************************@python.org> ,
Eric Wichterich <er*************@gmx.de> wrote:
Hello Pythonistas,

I am trying to get certain (self-written) libraries imported into my
scripts using statements like

"from library import function.py".

But they are not being found.

I think that the pythonpath-variable must be expanded to the location
to this libraries.

But, I can't find any usable information using Google on how to set up
the pythonpath properly.
I don't even know where to look for the pythonpath-variable?

It would be great if anyone could help me out on this?


You can define the environment variable PYTHONPATH to include any paths
you like, and python will read this info when it starts up.

On MacOS X you have several choices for defining environment variables.
All work for unix command-line apps, but only can be seen by GUI apps,
so it's the one I recommend you use: put the information into a file
..MacOSX/environment.plist (which you will probably have to create).
Instructions are available at
<http://www.astro.washington.edu/owen/AquaEnvVar.html>

If you only care about command-line usage then you can edit ~/.cshrc and
include a command such as
setenv PYTHONPATH "/path/one/:path/two:..."
(note: .cshrc may not be the best choice, but it certainly works).

Warning: do NOT mix these two techniques. At least in Jaguar,
environment.plist completely overrides env variables defined or modified
in .cshrc.

-- Russell
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Rami A. Kishek | last post: by
4 posts views Thread by r.e.s. | last post: by
8 posts views Thread by Tero Pihlajakoski | last post: by
3 posts views Thread by D Denholm | last post: by
10 posts views Thread by sushant.sirsikar | last post: by
reply views Thread by Michael Yanowitz | last post: by
4 posts views Thread by mhearne808[insert-at-sign-here]gmail[insert-dot-he | last post: by
1 post views Thread by Aljosa Mohorovic | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.