Reputation: 13172
I want to completely replace python 3 with python 2 in arch linux. I have already read https://wiki.archlinux.org/index.php/Python but it only provides a temporary fix. I need to ensure that when I call
#!/usr/bin/python
My program is using python 2 instead of python 3.
Upvotes: 16
Views: 30330
Reputation: 177
Changing the default symlink is a bad idea, and it gets recreated on python3 updates. Instead, create a local python
override:
sudoedit /usr/local/bin/python
Paste this inside and save the file:
#!/bin/bash
exec python2 "$@"
Don't forget to make it executable:
sudo chmod +x /usr/local/bin/python
Upvotes: 10
Reputation: 8272
In Arch, /usr/bin/python
is actually a symlink to python3. Assuming you've already installed python2, as root, change the symlink to point to python2:
cd /usr/bin
ls -l python
lrwxrwxrwx 1 root root 7 5 sept. 07:04 python -> python3
ln -sf python2 python
ls -l python
lrwxrwxrwx 1 root root 7 Dec 11 19:28 python -> python2
If you're using the python2-virtualenv
package, then do the same for /usr/bin/virtualenv
:
cd /usr/bin
ln -sf virtualenv2 virtualenv
Upvotes: 39