In this post, we will Install Python 3.7.0 on Ubuntu 18.04. This is the latest version of the Python Programming Language.
What’s New?
Python 3.7 gives us some new features, including:
- Postponed evaluation of type annotations
- async and await are now reserved keywords
- New contextvars and dataclasses library modules
- New breakpoint() function
- and more
For more checkout the What’s New in Python 3.7 page.
Preparations
Perform all the updates.
apt update && apt upgrade -y
Install everything we will need to build the source for Python.
apt install build-essential -y apt install libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev -y
First, download the source tarball.
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
Unzip the tarball.
tar -xzvf Python-3.7.0.tgz
Next, we need to configure the build.
./configure --enable-optimizations
This will enable a release build of the code.
The down side is that it will take a while to build because it will be running tests that will optimize the binary to run faster.
If you don’t care then you can run configure without the –enable-optimizations flag.
Build Python
Next we need to build the binaries.
make
Once the build is done we can install the binaries.
make install
Python 3.7 is now installed.
# python3 Python 3.7.0 (default, Oct 1 2018, 13:10:35) [GCC 7.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>>
Create a Virtual Environment
Since Python 3.3 venv has been included with Python.
To create a virtual environment use the -m venv command line option.
$ python3 -m venv ../venv/py37test
Now you can activate the environment with:
$ source ../venv/py37test/bin/activate
You now have a Python 3.7 virtual environment.
(py37test) bill@dev:~/Development/python/py37test$ python --version Python 3.7.0
The virtual environment is complete with Pip version 10.0.1.
$ pip --version pip 10.0.1 from /home/bill/Development/python/venv/py37test/lib/python3.7/site-packages/pip (python 3.7) (py37test) bill@dev:~/Development/python/py37test$
Need more Python training?
Checkout these awesome Python courses on Pluralsight. Pluralsight has great video training courses at a great price. I use Pluralsight every time I need to learn something new.
Conclusion
In this post we learned how to Install Python 3.7.0 on Ubuntu 18.04.
If you liked this post then please share and comment.
The post Install Python 3.7.0 on Ubuntu 18.04 appeared first on AdminTome Blog.