How to Solve Python3 Command Not Found Error in Bash

Yahya Irmak Feb 02, 2024
  1. Install python3 on Linux
  2. Solve python3 command not found Error in Bash
How to Solve Python3 Command Not Found Error in Bash

Python is a high-level, general-purpose programming language. It has two major versions, Python 2.x and Python 3.x.

This article will explain how to install Python3 and solve the bash: python3: command not found error in Linux Bash.

Install python3 on Linux

The official Python tool must be installed on your computer to execute programs created with the Python programming language. The python3 tool can be installed on Linux distributions with the following commands.

Install python3 tool for Arch Linux.

sudo pacman -S python

Install python3 tool for Ubuntu and Debian.

sudo apt-get install python3

Install python3 tool for Fedora.

sudo dnf install python3

Besides these, the python3 tool can be installed manually. Download the file from the official repository with the curl tool and save it as Python-3.10.2.tar.xz.

curl https://www.python.org/ftp/python/3.10.2/Python-3.10.2.tar.xz -o Python-3.10.2.tar.xz

Extract the file contents.

tar -xvf Python-3.10.2.tar.xz

Navigate to the Python-3.10.2 directory and execute the configure file. Then use the make command.

cd Python-3.10.2
./configure
make
make install

You can successfully install the python3 tool by choosing the one that suits you best from these options. Now you can execute the programs you want using the python3 programname command.

Solve python3 command not found Error in Bash

You may be using the wrong version if you get a bash: python3: command not found error while executing a Python program. First, check the Python versions installed on your system to fix the problem.

python3 --version
python2 --version
python --version

python –version

Usually, python is used with Python 2.x and python3 with Python 3.x. If you want to execute Python3 programs, try typing python3 instead of python.

python3 programname

If you have Python3 installed on your system, you will be able to run the program successfully in this way. However, if you do not want to type python3 every time, you can add an alias to the .bashrc file.

alias python="python3"

Thus, you can execute Python3 programs by just typing python.

Author: Yahya Irmak
Yahya Irmak avatar Yahya Irmak avatar

Yahya Irmak has experience in full stack technologies such as Java, Spring Boot, JavaScript, CSS, HTML.

LinkedIn

Related Article - Bash Error