on my computer
~$ python -V Python 3.2.1
but I get into problems when I run some python programs. my guess is (or at least I want to try this) that there is some backward compatibility issues, and I want to run those python scripts with
python2 2.7.2-2
which is also installed on my system but I do not know how to make it as the (temporary) default python. The python script starts with
#!/usr/bin/env python
and I am using arch linux.
The reason why Python 2 is invoked when python is run lies in the one of the historical point of PEP 394 -- The "python" Command on Unix-Like Systems: The python command should always invoke Python 2 (to prevent hard-to-diagnose errors when Python 2 code is run on Python 3).
To change to python3, you can use the following command in terminal alias python=python3 . But that only work for the current running process in terminal.
You can use virtualenv
# Use this to create your temporary python "install" # (Assuming that is the correct path to the python interpreter you want to use.) virtualenv -p /usr/bin/python2.7 --distribute temp-python # Type this command when you want to use your temporary python. # While you are using your temporary python you will also have access to a temporary pip, # which will keep all packages installed with it separate from your main python install. # A shorter version of this command would be ". temp-python/bin/activate" source temp-python/bin/activate # When you no longer wish to use you temporary python type deactivate
Enjoy!
mkdir ~/bin PATH=~/bin:$PATH ln -s /usr/bin/python2 ~/bin/python
To stop using python2, exit
or rm ~/bin/python
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With