2

I have installed different python versions on my Linux Mint DE. I used the update-alternatives --set statement to easily switch between the different versions.

Unfortunately sometimes apt-get install or upgrade or something similar have problems recognizing the correct python path. It seems to want to use python2.7, although I have set the correct alternative. I guess apt-get can't find out that /usr/bin/python points to /etc/alternatives/python and that to /usr/bin/python2.7.

If I manually create a symbolic link directly from /usr/bin/python to /usr/bin/python2.7 apt-get finishes without an error.

How can I use the alternatives option so that apt-get can correctly detect and use the configured python version?

2

I'm thinking this problem might have something to do with how the shell (Bash) hashes the paths to executables when they're called.

excerpt from bash man page

Bash uses a hash table to remember the full pathnames of executable files (see hash under SHELL BUILTIN COMMANDS below). A full search of the directories in PATH is performed only if the command is not found in the hash table.

You can interrogate the hash using the hash command like so:

$ hash -l
builtin hash -p /usr/sbin/update-alternatives update-alternatives
builtin hash -p /usr/bin/man man
builtin hash -p /bin/ls ls

You can cause the hash to "forget" everything with the -r switch:

$ hash -r
manny@manny:~$ hash -l
hash: hash table empty

I would try running a hash -r prior to running apt-get to see if that resolves the issue.

Also I'd take a look at the output from update-alternatives --query <command> to make sure it contains the values you think it should. Here's mine for java just for an example:

$ update-alternatives --query java
Name: java
Link: /usr/bin/java
Slaves:
 java.1.gz /usr/share/man/man1/java.1.gz
Status: auto
Best: /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
Value: /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java

Alternative: /usr/lib/jvm/java-7-openjdk-amd64/jre/bin/java
Priority: 1071
Slaves:
 java.1.gz /usr/lib/jvm/java-7-openjdk-amd64/jre/man/man1/java.1.gz

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.