upgrading default python version or install another python version in Linux
The accepted answer is good though, however I have found another hack trick to this problem and I think it's pretty simple.
At the location of /usr/bin/
there are many python related files available. You can see the file python
is actually a link and it points to the python2
(which is pointed to python2.7
).
So whenever you command python it calls the python2.7
not python3.5
The solution is to delete the original python
link and make another link that points to python3.5
and make the newly link file name to python
.
And you are done. :D
Related videos on Youtube
Admin
Updated on September 15, 2022Comments
-
Admin over 1 year
I want to upgrade python's default version i.e
/usr/bin/python
in Linux.I have multiple python versions installed as
/usr/bin/python2.7 /usr/bin/python3.3
However,
python
command still returnspython2.7
# python Python 2.7 Type "help", "copyright", "credits" or "license" for more information. >>>
Now, I have installed a module, which got installed in the default version
2.7
.That's why I can't use
python3.3 script.py
, as it returns error for missing module.How to update this default version to
3.3
?Is there a way to install the module in
/usr/bin/python3.3
as well?Added: Module is
pexpect-2.3
.-
Alex Chamberlain over 10 yearsWhat version of Linux are you using? The only distribution that symlinks python to python3 is Arch AFAIK.
-
Wooble over 10 yearsHow did you install the module?
python3.3 setup.py install
should do the right thing, if you installed from source. -
Wooble over 10 years"Pexpect was written and tested with Python 2.5. It should work on earlier versions that have the pty module." would make me think there's no way it's going to run on Python 3.
-
Wooble over 10 yearspexpect-u looks like a fork that does work on python 3; haven't tried it myself.
-
-
Bakuriu over 7 yearsNote that there is a reason why those distribution use python2 as reference for the
python
executable: some programs are still not python3 ready. While (e.g.) Ubuntu is putting a hardwork moving towards python3, it still has to update quite some of its components which means that doing what you describe will currently break a lot of your system. Hopefully in one or two years the major distributions will move to python3 only, but until then I don't think this is a good idea. Just specifypython3
when launching your programs!