FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.

» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux General Discussion

LinkBack Thread Tools
Old 08-17-2012, 06:09 PM
Ben Booth
Default simple trick to make dealing with python 2/3 scripts easier

Lots of python scripts still use #!/usr/bin/python instead of explicitly
stating which version of python to use. Here's quick trick to make running
various python version 2 or 3 scripts easier:

remove the /usr/bin/python symlink and replace with this shell script:

#!/usr/bin/env bash
exec /usr/bin/"${PYTHON:-python3}" "$@"

Now you can set the PYTHON environment variable to be either python2 or
python3, depending on which version of python the script expects. Just don't
set PYTHON=python, or you'll get a recursive loop! The only problem with
this approach is that /usr/bin/python is owned by the python package, so if
you upgrade the python package it might create problems. Any one know of
some way to work around this problem?

Thread Tools

All times are GMT. The time now is 03:39 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org