ActivePython Scripts help with ?

Robin Munn rmunn at pobox.com
Fri Apr 25 12:21:29 EDT 2003


Hyperion <Sorry at ButNo.com> wrote:
[snip]
> 
> Wll I maniged to install it fine, but now I haven't got the slightest clue
> what to put at the top of my scripts so the interpreter or what ever can
> find them.
>  You no the little bit at the top that starts with,  #!
> 
> The ActivePython Install is setup here as follows:
> 
> ---------------
> /home/me/ActivePython-2.2/bin
> ---------------

In that case the Python interpreter should be:

    /home/me/ActivePython-2.2/bin/python

So at the start of your scripts you would put:

    #!/home/me/ActivePython-2.2/bin/python

Also don't forget to make your scripts executable ("chmod +x script.py")
or you won't be able to run them even with the right #! line.

> . I added that line to me PATH also in my /etc/profile  file as follows:
> 
> --------------------
> # Set the default system $PATH:
> PATH="/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/home/me/ActivePython-2.2/bin"
[snip]
> ------------------

Another alternative, since the python interpreter is in your PATH, is to
use /usr/bin/env to find it. This trick can come be handy if you want
other people to be able to use your python scripts. Most people put
python in /usr/bin or /usr/local/bin, so they would have to change the
#! line in your scripts if you use "#!/home/me/...". But if you put this
line at the start of your scripts:

    #!/usr/bin/env python

Then people who didn't install Python in the same place as you will
still be able to use your scripts verbatim.

> So anyways can someone please help me with what I put in the top of my
> scripts after the , #! ,  so I can run them.
> And if there are any linux guru's out there that could check that PATH thing
> out and see if its ok, I would be greatfull.

Looks to me like you included all the needed directories. One caveat,
though: your system path (used by all users on your system) includes a
part of your home directory (used by only you). Are you planning on
making your home directory world-readable (i.e., readable by other users
on your machine)? If you're the only user on your system, that's not a
big security concern; but you should be aware of the potential security
implications of what you're doing. That's why most people will install
Python in a standard place like /usr/local or /opt. (If you've never
heard of /opt, basically it's designed to work a bit like the Program
Files directory in Windows. Go read section 3.12 of the Filesystem
Hierarchy Standard -- http://www.pathname.com/fhs/2.2/fhs-3.12.html --
if you want all the details).

-- 
Robin Munn <rmunn at pobox.com>
http://www.rmunn.com/
PGP key ID: 0x6AFB6838    50FF 2478 CFFB 081A 8338  54F7 845D ACFD 6AFB 6838




More information about the Python-list mailing list