My Python Installation Is Broken/corrupted. How Do I Fix It?
Solution 1:
Do
sudo update-alternatives --remove-all python
sudo ln -sf /usr/bin/python2.7 /usr/bin/python
Solution 2:
I got the same issue while upgrading ubuntu 18 to 19, this made it:
sudo rm /usr/bin/python
sudo ln -s /usr/bin/python2.7 /usr/bin/python
do-release-upgrade
From:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-release-upgrader/+bug/1825655
Solution 3:
For me, nothing worked except this one:
unlink /usr/bin/python3
ln -s /usr/bin/python3.7 /usr/bin/python3
Credit: https://josephgeis.dev/2020/04/upgrading-to-ubuntu-20-04-python3/
Solution 4:
This is easily fixed by installing the python27
package via yum
. It should install in /usr/bin
, and may overwrite the /usr/bin/python
symlink that should be pointing to 2.6. If it did (just run ls -l python*
in /usr/bin
to see), remove the symlink and point it back to 2.6. Next create a symlink for /usr/local/bin/python
pointing at /usr/bin/python2.7
. Finally, modify your ~/.bashrc
or ~/.bash_profile
(whichever you use) to have /usr/local/bin
before /usr/bin
in your PATH:
export PATH=/usr/local/bin:$PATH
at the very end of the file. This way, /usr/bin/python
remains linked to Python 2.6, which is what the system expects, and when you run python
at the command line it'll start up 2.7. You shouldn't have to make any changes to the yum
script either - just blanket replacing python
with python2.6
without understanding what you're doing is not a very good idea.
I'd also recommend installing Python 3.4 in /usr/local/bin
if possible, where the binary will be named python3
by convention. Even if it installs in /usr/bin
, you'll still have the choice of running python3
or python3.4
to specify which version you want. I work on a CentOS system that has each version of Python from 2.4 up to 3.4 installed, all in /usr/local/bin
(I'm sure this was done manually, and not via yum
), while the only python*
in /usr/bin
is 2.6. I couldn't find a python3
package for RedHat (I may not have been looking hard enough), so I'd recommend building the latest version from source (3.4.3 as of this writing). Unzip the tarball in a suitable directory, check out the README file, then, in the Python-3.4.3
directory, run ./configure --help
to see what the options are, and if you need to change anything. As long as you have gcc
installed, and don't need to link to any weird math libraries or anything, you should just be able to run:
./configure
makemake test
sudo make install
and it'll install to /usr/local/bin
. Check the messages at the end of the make
step, as it'll list any modules it wasn't able to build there. Fails usually happen because you don't have a required library installed, so look in setup.py
in the base directory in the detect_modules()
function (starting on line 449, and stretching all the way down to line 1564). Install both the lib and the -devel
packages so you get the necessary headers.
This same process can also be followed if you want to install the latest 2.7.9, instead of RH's 2.7.5. One of the major (in my eyes) advantages of 2.7.9 is that pip
is installed by default, making third-party module installation that much easier.
Good luck!
Post a Comment for "My Python Installation Is Broken/corrupted. How Do I Fix It?"