Ravi Chhabra
Ravi Chhabra

Reputation: 1730

Making Python default to another version installed on a shared host

I am on a shared host and can not change the symbolic link to Python2.4, it defaults to 2.3. I tried creating a sym link in the director I would be working on to 2.4, but it seems the the 'global' python interpreter under /usr/bin/python take presedence unless I run it as ./python. What alternative ways are there to override this behaviour?

Upvotes: 1

Views: 413

Answers (2)

a2800276
a2800276

Reputation: 3328

If you're working from the shell, you can create a symbolic link as suggested and update your path in the .profile. This is described in a previous post.

In case these are CGI/whatever scripts that you only run on your shared host, you can alter the shebang line at the top of your scripts that tell the system what interpreter to run the script with.

I.e. change

#!/usr/bin/env python

to

#!/whatever/the/path/to/your/version/python

Upvotes: 3

Bombe
Bombe

Reputation: 83853

Create a symlink and prepend the path to your PATH variable:

ln -s /usr/bin/python2.4 $HOME/bin/python
export PATH="$HOME/bin:$PATH"

Upvotes: 2

Related Questions