Need Help Re:PATH

Randall Hopper aa8vb at yahoo.com
Mon Mar 20 07:17:46 EST 2000


Snoopy:
 |Randall Hopper:
 |>
 |> I believe you need to put an "export" before your declarations for bash.
 |> Also, when you say "bash_profile", the user file for this is $HOME/.bashrc
 |>
 |> Try this:
 |>
 |>     cd $HOME
 |>       echo $PYTHONPATH                 <-- Make sure /home/charly/Pydir
 |>                                            shows up here
 |
 |    I did the above but  it returns me to the "Prompt".  Nothing else shows.

Ok, that means you don't have a PYTHONPATH environment variable set in your 
default environment.  We'll get to that in a sec...

 |>     export PYTHONPATH=/home/charly/Pydir    <-- If not, just do this
 |>     python
 |>     >>> import mymodule
 |
 |I did the above and it seem to work.  However it is only effective while
 |I am logged in.  If I loggout and log back again I have to use the above
 |in order for things to work. 

Right.  You're setting this environment variable only for this particular
shell.  It's lost when you kill that shell.  But that works for you.

 |The book say that in order to make it permanent the

 |"PYTHONPATH=$PYTHONPATH:.:/home/charly/Pydir "  should be placed in the
 |"/home/charly/.bash_profile"  file.
 |
 |I've done this as well but for some reason it's not taking efect.  

I'm not a bash guru, so I'll let you figure that one out.  First, make sure
you are using bash and not some other shell.  echo $SHELL should tell.
If you are, I know that inserting:

    export PYTHONPATH=/home/charly/Pydir

into ~/.profile or ~/.bashrc should do the trick.  Then each new bash shell
you start up will have this environment variable set so you don't have to
do it manually each time.  Put it at the top of the file.

 |I am either doing something wrong in the configuration or there is a Bug
 |somewhere.  I've been browsing myt books as well as the Tutorials or the
 |past 2-weeks and can't find the answer.  Purhaps if I bug people in these
 |groups long enough,some one will help me see the light.  I sure would
 |appreciate it.

Like one of your other responses said, don't do that :-) Now that we know
setting PYTHONPATH fixes your module search problem, we're no longer in
Python-land.  You now need to learn how to set environment variables for
your shell, whatever shell that may be.  "echo $SHELL" should tell you
which shell you are using.  Then run "man bash" or "man
<whatever-shell-i'm-using>" for details.

Basically, for an sh-derived shell (ksh/bash/etc.), you can insert this in
~/.profile:

        export PYTHONPATH=mydir1:mydir2:mydir3

And for a csh-derived shell (csh/tcsh/etc.), you can insert this in ~/.cshrc:

        setenv PYTHONPATH mydir1:mydir2:mydir3

Oh, and please configure your mailer to wrap lines at 80 characters.  It
makes your messages easier to read and more likely to get responses.

Good luck!

-- 
Randall Hopper
aa8vb at yahoo.com




More information about the Python-list mailing list