How to Setup Python Development Environment in Ubuntu and Fedora

3 min


This article helps you with the basics and steps needed to set up your Python development environment in Ubuntu and Fedora. 

Python became popular in the last couple of years due to its powerful libraries, easy syntax, and portability. It is being used currently almost every system across businesses.

So, if you are trying to set up your Python box and wondering how to begin etc, then you are at the right place. Here, I tried to give you some steps for you to get you started.

Setup Python Development Environment in Ubuntu and Fedora

Python Versions

If you are starting up Python development fresh, then it is recommended that you use the latest Python 3.x for your development as Python 2.x will be end-of-support by the year 2020. On the same note, if you are running any application based out of Python 2.x then consider migrating, compiling it to Python 3.x as soon as possible. 

If you are running the latest distributions as of today for Fedora or Ubuntu then you should have Python 3.x already installed and set as default interpreter. For example, Fedora 32 and Ubuntu 20.04 LTS which is currently available, have Python 3.x as default Python shell. 

A quick way to find out what Python version you have is running below command from a terminal in both Ubuntu and Fedora.

python2
python3
python3
python3

If you are running earlier versions of Ubuntu or Fedora, then you can install the latest Python 3.x using below commands:

Ubuntu

sudo apt install python3

Fedora

sudo dnf install python3

Also, run below command to find out the path of your Python executable in the current system:

which python

Switching Versions as the default interpreter

If your system has multiple Python versions installed – 2.x and 3.x and want to switch between them, then it is indeed possible. 

If you have only one version installed, you can skip this section.

To switch, first, run python from the terminal to find out the default executable path. Ideally, it should be /usr/bin/python. Now, to find out the symbolic link to the executable run below.

ln -l /usr/bin/python
lrwxrwxrwx 1 root root .... /usr/bin/pyhton -> python2

Now check out the $PATH variable to find out the order of path concatenation which system looks up for executables.

echo $PATH
PATH-Variable
PATH-Variable

As you can see /usr/local/bin is preceding the /usr/bin/ then you can create a soft symbolic link to python3. Then your interpreter should pick up the latest Python 3 instead of Python 2 while running python command. 

ls -s /usr/bin/python3 /usr/local/bin/python

Now you should logout and login again to clear any hash entries, or you can run hash -r to clear them out.

SEE ALSO:   How to Install Python 3.7.2 in Ubuntu 18.04 LTS

Now you can run python from the terminal and you should have the latest Python 3 picked up.

Python IDE

An integrated development environment (IDE) helps you to write your code, compile, and execute. There are several free Python IDE is available – such as PyCharm, Eclipse, Eric, etc, which you can use. That’s would be another write up on their pros and cons. 

If you download Python from the official python.org website then Python accompanies a default development environment called IDLE. IDLE is good for starting up your system and later you can decide to pick any of the best free Python IDE available.

IDLE is not included in Ubuntu and Fedora along with python as default, you have to manually install it. Run below commands from the terminal to manually install IDLE.

Ubuntu

sudo apt install idle

Fedora

sudo dnf install python-tools

Once installed, you can launch IDLE from the command line idle or search from the application.

IDLE-environment`
IDLE-environment

Now, you can use IDLE to start your development. Most of the basic options you can find in the File menu of IDLE.

I hope, this guide explains the things you should know before you start your Python development. Although this guide is primarily targetted to Ubuntu and Fedora, you can still follow the instructions for all Ubuntu and Fedora-based distributions as well. If you are facing problems with Python environment setup, let me know in the comment section below. 


We bring the latest tech, software news and stuff that matters. Stay in touch via Telegram, Twitter, YouTube, and Facebook and never miss an update!

Join our Telegram channel and stay informed on the move.

Also Read


Like it? Share with your friends!

Arindam

Creator of debugpoint.com. All time Linux user and open-source supporter. Connect with me via Telegram, Twitter, LinkedIn, or send us an email.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

2 Comments
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
2
0
Would love your thoughts, please comment.x
()
x