Frin-Ed

Installing Python and VSCode in openSUSE

By Satyajeet Sahu

Published: 23-Oct-2022

This blog is more inclined towards people who want to write python codes using VSCode IDE, in openSUSE. But I guess the steps are similar for other linux distros also.

At the time of writing this, openSUSE Leap comes with builtin Python 3.6, which is a fairly older version as compared to current Python 3.10. So in this blog we'll try to install the newest python version and after that, VSCode.

By the way, I am using openSUSE Leap 15.4.

Here are the sections for quick access:

  1. Installing Build essentials
  2. Installing Python
  3. Installing VSCode
Additional Sections:

1. Installing Build Essentials

The build essentials like gcc compiler and make are installed by default in distros like Ubuntu, so, you can skip this if you are using an Ubuntu setup. But if you’re using openSUSE like me, then here are the following commands you can type in the terminal:

                        
                            $ zypper info -t pattern devel_basis
                            
$ sudo zypper install -t pattern devel_basis
$ sudo zypper install libffi-devel openssl-devel zlib-devel

This will install gcc and make which are essential to install python.

2. Installing Python

Before installing Python, make sure your build essentials are in place. Things that are written in the section above.

To install python, first download it from python.org > Downloads

It’ll download a tar.xz file, which you have to extract. Once extraction is completed, go to the extracted folder and do the following (it’s also written in the README.rst of the extracted Python folder):

                        
                            $ ./configure
                            
$ make

After this there’s an optional step that you can do, which actually took more than 3 hours in my laptop and I eventually had to skip it to save my time. It actually tests everything properly in python so that you can have a smooth experience. But it’s optional and you can go ahead without it. The step is:

                        
                            # this step is optional and takes around 2 hours to execute
                            
$ make test

After that is done, you can do:

                        
                            $ sudo make install
                        
                    

This will install the newest version of Python!

You can check the new version with the following command:

                        
                            $ python3 --version
                        
                    

But it’s not done yet. Check if your pip is working properly by using the following command:

                        
                            $ python3 -m pip list
                        
                    

It may happen that pip will give a logging error, which means that either pip is not properly installed or there’s a version issue. This can be fixed by upgrading the pip. To upgrade it, use:

                        
                            $ python3 -m pip install --upgrade pip
                        
                    

Then again try the command before this to check if things are right.

By this time everything should work fine (at least it did for me), and you’re ready to install VSCode.

3. Installing VSCode

You can also see these steps in this article: Click Here.

Do the following to install VSCode:

                        
                            $ sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc
                            

$ sudo sh -c 'echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ntype=rpm-md\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/zypp/repos.d/vscode.repo'

$ sudo zypper refresh
$ sudo zypper install code

This will install VSCode in your system.

You can install the Python Extension from Microsoft that is available in VSCode Extensions if you want to work properly with Python.

Note: If you face the issue of Debugger in the Python Extension not working properly, try installing the latest version of Python in your system, or downgrading the Python Extension to an earlier version.

Installing Git

To install git in openSUSE, use the following command:

                        
                            $ zypper install git
                        
                    

And you’ll have git installed in your system!