![]() |
VOOZH | about |
We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.
Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.
Follow TNS on your favorite social media networks.
Become a TNS follower on LinkedIn.
Check out the latest featured and trending stories while you wait for your first TNS newsletter.
Python seems to be everywhere, from data science to machine learning, and it ranks at number three on the Stack Overflow 2023 Developer Survey (just behind JavaScript and HTML/CSS). Python is relatively easy, powerful and versatile, making it a great choice for a first programming language.
Figure 1: The Stack Overflow 2023 Developer Survey ranks Python at number three.
And Fedora Linux is an excellent choice for running Python. To set up a Fedora Linux workstation to work with Python, you should only need to complete a standard Fedora installation and update the operating system and applications. After that, you’re ready to start learning Python.
But where do you begin? What must you install? This tutorial guides you through the steps leading up to writing your first Python code. It covers installation requirements, libraries, virtual environments and integrated development environments (IDEs) and gets you ready for your first programming lesson.
The four general steps are:
Before starting, be sure to get the latest version of Fedora Linux. At the time of writing, that is Fedora 39. You may do a bare-metal installation or create a virtual machine. Your Fedora distribution may install Python automatically, but there are additional considerations, such as Pip, libraries and development libraries. I’ll cover these components below.
Python is usually installed by default with Fedora, so there’s a good chance you don’t need to do anything yet. I’ll review some of the considerations around Python installations and briefly explain the installation process in case you need it.
One consideration is which Python version to install. Python 2 has been in use for a long time, and many applications rely on it. If you intend to maintain older applications, you may need to know something about Python 2. However, if you’re just starting with Python, I suggest focusing on version 3, as it is the current standard.
First, determine whether Python is installed on your system by typing python at the command prompt.
Figure 2: Typing the python command displays version information.
Fedora Linux includes Python, but if you need to install it, use the following two dnf commands:
$ sudo dnf upgrade --refresh
$ sudo dnf install python3
Type python to confirm the installation. The system will display the Python version (that’s Python 3.11.5 in the screenshot above).
Incidentally, you can use apt-get commands to install Python on Debian-based Linux devices:
$ sudo apt-get update
$ sudo apt-get python3
Ubuntu 20 and later ship with Python 3.
Like many programming languages, Python relies on code libraries to ease development and increase functionality. Libraries include prewritten code developers can reuse rather than having to create entirely new but repetitive code. Pip is a Python package manager for installing and managing Python features.
Pip is the standard package manager for Python applications, so it manages Python libraries and dependencies. It is usually installed by default with Python.
Type pip to see a help file and confirm the package manager is installed.
Figure 3: Type the pip command to display a help file for pip options.
Libraries provide access to system functionality. Python developers rely on libraries to use system resources to process code. Python includes a standard library with basic functionality. The Python community maintains many additional libraries, which extend the programming language’s capabilities, available for anyone’s use.
Pip lets developers access, install and use these libraries. Here are a few common libraries you may need as you delve into Python:
These libraries contain standardized code, permitting developers to reuse established code rather than rewriting it each time they need that functionality. Python developers have created hundreds of libraries.
If you would like to see which Python libraries are installed, enter $ sudo pip list at your command prompt.
Figure 4: Use pip to display installed Python packages.
Many new Python developers work directly with the base Python installation, adding libraries as needed. However, some projects may require different libraries, versions or settings. Users create Python virtual environments on top of the base installation to provide isolated and customized Python configurations for specific projects.
Python virtual environments exist in directory structures, so creating a new one means defining a new directory path. Here is an example:
$ python -m venv /new/environment/path
Consider creating a dedicated environments directory and building all virtual environment folder structures for your projects in it.
For new Python users, your project instructions may suggest you create a virtual environment.
IDEs provide features that make programming easier. These include error-checking, syntax highlighting, autocompletion and debugging tools. Many IDEs support Python because of its popularity, but two common IDEs are IDLE and PyCharm.
The Integrated Development and Learning Environment (IDLE) provides an environment for writing and testing Python code. It includes an interactive shell and a file editor to aid Python development.
Figure 5: The python3 command provides access to the Python command line.
The command line IDLE is usually included with Windows and macOS installations. You can also install IDLE to run in a graphical interface.
PyCharm is characterized by its user-friendly interface, enabling users to easily understand and work with Python code. Installing PyCharm on Fedora is straightforward. The application is a compressed tarball; use the following steps to add PyCharm to your system.
/opt directory:$ sudo tar xzf pycharm-*.tar.gz -C /opt/bin directory:$ cd /opt/pycharm-2022.2.4/bin
Note that the path may vary depending on the PyCharm version.$ sh pycharm.shThere are also Flatpak and Snap package manager installation options.
Python programs don’t need to be compiled like code developed in C or other languages. Python is an interpreted language, meaning your application should run if the destination system has Python installed. There may be dependencies or other variables, but that’s the general idea.
Python code files use the .py file extension.
You’ve set up your new Fedora Linux workstation for Python development by installing the language, adding any libraries, configuring virtual environments and using one or more IDEs. Default Fedora Linux installations typically include Python 3 and IDLE, but there is a lot of room for customization.
Your next step is selecting a Python project to start with. Here are a few ideas:
Another great resource is Jack Wallen’s extensive Python for Non-Programmers series. Steps for the projects above and more are only a Google search away. Educators may also be interested in Fedora’s Python Classroom Lab.
Python continues to evolve and improve. It’s never been easier to start with Python, and the Fedora Linux distribution is an excellent platform. Get ready to begin an exciting learning experience using these two essential tools.