How to set pythonpath in Mac OS X?

E

Eric Wichterich

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
 
J

Jorl Shefner

Eric Wichterich said:
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.
 
R

Russell E. Owen

Eric Wichterich said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top