How to install Python 3.6 on Ubuntu 22.04? - Stack Overflow
Unsure how to install python for playonlinux
How to install Python on Ubuntu?
python3 on Ubuntu
How do I install pip for the new Python version?
Will installing a new Python version break my system?
How do I make the new Python version the default?
Videos
Hey Reddit. I'm super new to ubuntu. (like 3 days ago I got my first machine running it.) and need some quick help. I want to install python so I can run code on the machine and I have no idea how to do that. I'm guessing it'll be something like "sudo install python3.9". thanks for the help!
To install Python 3.8 on Ubuntu version 23
Open your terminal and run these commands:
Install build dependencies
sudo apt-get update
sudo apt-get install -y build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm \
libncurses5-dev libncursesw5-dev xz-utils tk-dev \
libffi-dev liblzma-dev python3-openssl git
Download and extract Python 3.8 source code
mkdir ~/python38
cd ~/python38
wget https://www.python.org/ftp/python/3.8.16/Python-3.8.16.tgz
tar -xf Python-3.8.16.tgz
cd Python-3.8.16
Configure the build
./configure --enable-optimizations
Compile the source code
make -j$(nproc)
Install Python
sudo make install
Verify the installation
python3.8 --version
To create a virtual environment specify the Python version.
Example:
python3.8 -m venv venv
Assuming you need this simply for development reasons, there's no reason to install it, but rather build it only.
Follow the steps from @GODFREY but skip the install altogether - which most probably will screw up your system.
After make -j$(nproc) you get a python binary in the directory which you can test
./python --version
# => Python 3.10.14
Now in your python project you can use virtualenv directly to use the binary
# Assuming the source is in ~/Python-3.10.14
virtualenv -p ~/Python-3.10.14/python .venv
source .venv/bin/activate
python --version
# => Python 3.10.14
I have faced the same problems and could make it work by adding some additional flags when running ./configure
Here are my steps:
Step 1 – Prerequsities
sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev \
libgdbm-dev libnss3-dev libedit-dev libc6-dev
Step 2 – Download Python 3.6
wget https://www.python.org/ftp/python/3.6.15/Python-3.6.15.tgz
tar -xzf Python-3.6.15.tgz
Step 3 – Compile Python Source
cd Python-3.6.15
./configure --enable-optimizations -with-lto --with-pydebug
make -j 8 # adjust for number of your CPU cores
sudo make altinstall
Step 4 – Check the Python Version
python3.6 -V
As on Aug 2nd 2023, if anyone is still stuck with Segmentation fault (core dumped) issue. Here's the solution that worked for me. Thanks to Issue45700 - https://bugs.python.org/issue45700.
Ubuntu 22.04 comes with gcc 11. So let us install gcc-10 and compile Python with it.
Below are the steps to incorporate Workaround1 mentioned in Issue45700 -
apt-get install gcc-10 -y
< Download and extract python >
CC="gcc-10" ./configure
< Install python using make >
You can use additional flags mentioned in https://stackoverflow.com/a/72135545/8721632
Python is installed to all of our computers because it is useful framework for a variety of things .
To use the python interface from terminal just type python .
to check you python version just type python --version
to run a python script you need to type in the form :
./python_script_name.py
but very importantly it has to be executable first
chmod +x python_script_name.py
I hope it helps !
just type :
sudo apt-get install python
It will show you whether you have newest version of python or you should upgrade