Yum crashed with Keyboard Interrupt error - python-3.x

I installed the newer version of python (3.2.3) than the one available in Fedora16 (python2.7)
And now yum stops working. It shows the following error.
[root#localhost yum-3.4.3]# yum
File "/usr/bin/yum", line 30
except KeyboardInterrupt, e:
^
SyntaxError: invalid syntax
Please advice as how to resolve the error. It would be helpful as I am not able to update or install any package.

Because yum does not support Python3.
You can run command vi /usr/bin/yum, change /usr/bin/python to /usr/bin/python2 in first line.
Thus you can run the command yum by Python2 instead of Python3.
Note however that this will make your setup unsupported and thus unmaintainable (as does what you did). You will likely have other similar problems in the future with other system packages.
If you want to use an alternative Python installation, consider installing it into /usr/local, /opt or using pyenv.

This issue happens when user upgrades to python3, Just simply edit the file --> /usr/bin/yum and change to first line to --> "#!/usr/bin/python2"
The above solution wouldn't solve the all yum dependency problems, its better to run the below commands.
sudo ln -s /usr/local/bin/python3 /usr/bin/python3 (Mark latest python as python3)
sudo ln -sf /usr/bin/python2.7 /usr/bin/python (nake 2.7 as default python)
THanks,
Daman

I'm guessing you installed Python 3.2.3 from source and used "make install" as the last command. That command has the unfortunate side-effect of replacing the system installed version command "python" with the new version. Using "make altinstall" doesn't replace "python".
The command "python" is just a symbolic link to "python2", which in turn is a symbolic link to "python2.7". You should be able to restore "python" by executing the following command:
cd /usr/bin
sudo ln -s python2 python

Thanks Damanvir! Changing the line in /usr/bin/yum worked!
This is a little off topic and might be removed but it might help someone.
These are the steps I used to install Python 3.7 on Centos and fix the yum error.
Download from https://www.python.org/
tar -xvf
./configure --enable-optimizations
make
make install
OR
make altinstall
make altinstall is used to prevent replacing the default python binary file /usr/bin/python.
cd /usr/bin
Remove the current symbolic link to the previous version
rm python
OUTPUT: rm: remove symbolic link ‘python’? y
Find the location of the new version
whereis python3.7
OUTPUT: python3: /usr/local/bin/python3.7
Verify this is correct
/usr/local/bin/python3.7 --version
OUTPUT: Python 3.7.0
Create a symbolic link to the location of the new version
ln -s /usr/local/bin/python3.7 python
python --version
OUTPUT: Python 3.7.0
Yum commands will show the following error:
File "/bin/yum", line 30
except KeyboardInterrupt, e:
SyntaxError: invalid syntax
Change the top line of this file from using python to python2
vi /usr/bin/yum
#!/usr/bin/python2
Reference: https://tecadmin.net/install-python-3-7-on-centos/

The real answer - to ensure that you are back on a supportable version of python (in the event you are looking at this for an issue with RHEL 7).
cd /usr/bin
sudo unlink python
sudo ln -s python2 python

Your yum looks for python2. Let's use 'alternatives' to switch between pythons2 and python3.
run --> sudo alternatives --config python
Enter to keep the current selection[+], or type selection number:
If you don't configure it. How to do that?
sudo alternatives --install /usr/bin/python python
/usr/local/bin/python3.8 60
sudo alternatives --install
/usr/bin/python python /usr/bin/python2 50

It's only a binary link issue. You can copy the working /usr/bin/python2 from any system and copy to current system location /usr/bin/python2
#cd /usr/bin
#ln -s python2 python

Related

Remove Link Pointing to Old Version of Program in Linux

I installed Python 3 with:
yum install python3 -y
When I do:
which -a python3
I get:
/usr/bin/python3
Which is correct.
However, if I enter:
python3
I get:
-bash: /usr/local/bin/python3: No such file or directory
Apparently, python3 is still linking to a prior version which I have removed. How can I fix this so my system recognizes Python 3 being in /usr/bin/python3 instead of /usr/local/bin/python3.
Since you're dealing with an updated PATH starting a new terminal session should pickup this change.
As stated on the comment section this was the case.
For completeness, if the new path (/usr/bin/python3) is stil not on your PATH on the new session you could manually add it on /etc/profile (globally) or ~/.bash_profile (for your user, assuming you are using bash)

How to change python3 to default in linux mint

I have a little problem with changing python3 to default in newly installed operating system linux Mint 19.3. It was pretty easy on Ubuntu 16.04 but now I need small help here.
So, I run
python --version
and got this
Python 2.7.15+
Than I run
python3 --version
and this was the result
Python 3.6.8
After entering this command
sudo update-alternatives --config python
I received obvious info
update-alternatives: error: no alternatives for python
Both version of python are located in /usr/bin folder.
The issue occurs when I'm trying to change python3 to as a default by typing the command
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6
The terminal outputs the following
update-alternatives: --install needs <link> <name> <path> <priority>
Any help here would be welcome.
In your case, priority is missing, just append 1 at the end of the command like this :
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 1
To define python3 as your default version of python on linux, you need to add a specific line to .bashrc file located in your home directory.
Here is a simple method to do so through command line interface (termianl).
Run:
$ echo "alias python='python3'" >> .bashrc
$ source .bashrc
then run python --version to check if the change has applied.
#darkfidis answer is correct. But you may also need to run to set or change the default python version.
sudo update-alternatives --config python

installed python 3x on mac but terminal still show version still 2x

I installed python 3x via home brew, the process was successful.
However when I check version, it shows 2x
here is the terminal output
➜ ~ brew install python
Warning: python 3.7.2 is already installed, it's just not linked
You can use `brew link python` to link this version.
➜ ~ brew link python
Linking /usr/local/Cellar/python/3.7.2... Error: Permission denied # dir_s_mkdir - /usr/local/Frameworks
➜ ~ sudo brew link python
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
➜ ~ python -V
Python 2.7.10
I think I need to modify some kind of path. And do some magic then pray...lol
Anyway anyone know how to get this work on my machine? I'm mac latest
First, solve your permission problem by running the official command from the Homebrew Documentation, Troubleshooting page
cd /usr/local && sudo chown -R $(whoami) bin etc include lib sbin share var opt Cellar Caskroom Frameworks
Then run brew link python
And finally run echo $PATH and check that your /usr/local/bin has precedence over other directories.
you could do brew uninstall python3 and install it from the python website here https://www.python.org/
When you go install a module you do pip3 install packageName
And when you run a program you could run it from your IDE (I recommend VSCode) or run it from the terminal with python3 drag_python_file_here
you have to use python3 instead of python on Mac so like python3 path/to/file.py and pip is now pip3 so like pip3 install pillow

csvkit in2csv command not working

I followed installment instructions mentioned here
Its a simple pip install command
After that I went to my linux terminal and wrote in2csvbut got the following error:
/usr/bin/in2csv: No such file or directory
Originally I tried to install it using the command:
sudo apt-get install python3-csvkit
And the in2csv command used to work on terminal, but it appears to work under python 3 installation and I need it under my python2.7.
so I uninstalled the python3-csvkit, and installed it again using pip install, but again its not working from terminal, this way.
Any ideas why, and how to solve it?
in2csv command manual: here
I just had this problem and solved with:
sudo pip install csvkit
Without the sudo pip installs csvkit in /home/username/.local/lib/python2.7/site-packages and probably puts the executable in /home/username/.local/bin. You could avoid the sudo by adding that to your shell PATH.

UltiSnips requires py >= 2.6 or any py3

I'm trying to install UltiSnips in different way but the same message appears each time when I launch vim.
Python 2.7 is installed but it seems that vim has been installed before the 2.7 version.
I tryed to reinstall vim using this link:
$ sudo apt-get install mercurial libssl-dev
$ sudo apt-get build-dep vim
$ hg clone http://hg.debian.org/hg/pkg-vim/vim
$ cd vim
$ hg checkout unstable
$ debian/rules update-orig
$ dpkg-buildpackage -i -I
$ cd ..
But the same problem remains.
Thanks
You don't provide much information to help. You can check whether your Vim has Python via :py print "yes". For the Python version, check the :version output. It will contain something like -lpython2.7.
When you compile Vim yourself, you need to enable the Python integration by passing ./configure --enable-pythoninterp.
I had the same problem with NeoVim on Ubuntu. Running :CheckHealth pointed me into the right direction. Creating the following softlink solved the problem for me:
sudo ln -s /usr/bin/python /usr/local/bin/python
Maybe obvious to most, but not to me was the fact that the neovim module had to be installed. On ubuntu, installing it using pip did the trick for me:
sudo pip3 install neovim
To install the module for python 3, I suppose pip3 has to exchanged for pip for python 2.
Download the source code from http://www.vim.org/.
Then
cd vim
make clean
./configure --prefix=/opt/local --with-features=huge --enable-pythoninterp=yes --enable-multibyte --with-vim-name=vim --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu
make
sudo make install
I had the same problem after installing UltiSnips, my simple solution was to type inside vim :version where python3 wasn't install. I solve this installing vim-gtk3, try sudo apt install vim-gtk3 after installing gtk3 the message disapper and my vim launches normally ;)

Resources