役に立ちましたか?

質問

How to Install Python 3.4.4 on Ubuntu

UbuntuPythonSoftware & Coding

Python is a general-purpose interpreted, interactive, object-oriented, and high-level programming language. It was created by Guido van Rossum during 1985- 1990. Like Perl, Python source code is also available under the GNU General Public License (GPL).This article describes “How to install Python on Ubuntu”

Installing Required Packages

To install python, it should require prerequisites as shown below-

$ sudo apt-get install build-essential checkinstall

The sample output should be like this –

Reading package lists... Done
Building dependency tree
Reading state information... Done
build-essential is already the newest version.
The following packages were automatically installed and are no longer required:
   gtk2-engines-pixbuf libbs2b0 libopusfile0 libpyside1.2 libqmmp-misc
   libqmmpui0 libshiboken1.2 libsidplayfp libtidy-0.99-0 linux-headers-4.2.0-27
   linux-headers-4.2.0-27-generic linux-image-4.2.0-27-generic
   linux-image-extra-4.2.0-27-generic linux-signed-image-4.2.0-27-generic
   php7.0-opcache python-beautifulsoup python-feedparser python-html2text
   python-magic python-oauth2 python-pyside.qtcore python-pyside.qtgui
   python-pyside.qtnetwork python-pyside.qtwebkit python-pysqlite2 python-regex
   python-sqlalchemy python-sqlalchemy-ext python-support python-unity-singlet
   python-utidylib
Use 'apt-get autoremove' to remove them.
The following NEW packages will be installed:
   checkinstall
0 upgraded, 1 newly installed, 0 to remove and 1 not upgraded.
Need to get 121 kB of archives.
After this operation, 516 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://in.archive.ubuntu.com/ubuntu/ trusty/universe checkinstall amd64 1.6.2-4ubuntu1 [121 kB]
....................................................................

To install supportive libraries, use the following command –

$ sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev

The output should be like this –

Reading package lists... Done
Building dependency tree
Reading state information... Done
libc6-dev is already the newest version.
libc6-dev set to manually installed.
The following packages were automatically installed and are no longer required:
   gtk2-engines-pixbuf libbs2b0 libopusfile0 libpyside1.2 libqmmp-misc
   libqmmpui0 libshiboken1.2 libsidplayfp libtidy-0.99-0 linux-headers-4.2.0-27
   linux-headers-4.2.0-27-generic linux-image-4.2.0-27-generic
   linux-image-extra-4.2.0-27-generic linux-signed-image-4.2.0-27-generic
   php7.0-opcache python-beautifulsoup python-feedparser python-html2text
   python-magic python-oauth2 python-pyside.qtcore python-pyside.qtgui
   python-pyside.qtnetwork python-pyside.qtwebkit python-pysqlite2 python-regex
   python-sqlalchemy python-sqlalchemy-ext python-support python-unity-singlet
   python-utidylib
Use 'apt-get autoremove' to remove them.
The following extra packages will be installed:
   libexpat1-dev libfontconfig1-dev libfreetype6-dev libice-dev libpng12-dev
   libpthread-stubs0-dev libsm-dev libssl-doc libtinfo-dev libx11-dev
   libx11-doc libxau-dev libxcb1-dev libxdmcp-dev libxext-dev libxft-dev
   libxrender-dev libxss-dev libxt-dev tcl-dev tcl8.6-dev tk8.6-dev
   x11proto-core-dev x11proto-input-dev x11proto-kb-dev x11proto-render-dev
   x11proto-scrnsaver-dev x11proto-xext-dev xorg-sgml-doctools xtrans-dev
   zlib1g-dev
.....................................................................

Downloading Python

To download python use the following commands-

$ cd /usr/src
$ sudo wget https://www.python.org/ftp/python/3.4.4/Python-3.4.4.tgz

The sample output should be like this –

--2016-03-18 11:13:18-- https://www.python.org/ftp/python/3.4.4/Python-3.4.4.tgz
Resolving www.python.org (www.python.org)... 103.245.222.223
Connecting to www.python.org (www.python.org)|103.245.222.223|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 19435166 (19M) [application/octet-stream]
Saving to: ‘Python-3.4.4.tgz’

100%[==============================================================>] 1,94,35,166 819KB/s in 27s
..................................................

Now extract the downloaded package as shown below-

$ sudo tar xzf Python-3.4.4.tgz

Compiling Python Source

To compile Python source, use the following command –

$ cd Python-3.4.4
$ sudo ./configure

The sample output should be like this –

checking sys/bsdtty.h presence... no
checking for sys/bsdtty.h... no
checking sys/event.h usability... no
checking sys/event.h presence... no
checking for sys/event.h... no
checking sys/file.h usability... yes
checking sys/file.h presence... yes
checking for sys/file.h... yes
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/kern_control.h usability... no
checking sys/kern_control.h presence... no
checking for sys/kern_control.h... no
checking sys/loadavg.h usability... no
checking sys/loadavg.h presence... no
checking for sys/loadavg.h... no
checking sys/lock.h usability... no
checking sys/lock.h presence... no
checking for sys/lock.h... no
checking sys/mkdev.h usability... no
checking sys/mkdev.h presence... no
checking for sys/mkdev.h... no
checking sys/modem.h usability... no
...................................................

use altinstall to prevent replacing the default python binary file /usr/bin/python as shown below –

$ sudo make altinstall

The sample output should be like this –

Compiling '/usr/local/lib/python3.4/tkinter/test/widget_tests.py'...
Compiling '/usr/local/lib/python3.4/tkinter/tix.py'...
Compiling '/usr/local/lib/python3.4/tkinter/ttk.py'...
Compiling '/usr/local/lib/python3.4/token.py'...
Compiling '/usr/local/lib/python3.4/tokenize.py'...
Compiling '/usr/local/lib/python3.4/trace.py'...
Compiling '/usr/local/lib/python3.4/traceback.py'...
Compiling '/usr/local/lib/python3.4/tracemalloc.py'...
Compiling '/usr/local/lib/python3.4/tty.py'...
Compiling '/usr/local/lib/python3.4/turtle.py'...
Listing '/usr/local/lib/python3.4/turtledemo'...
Compiling '/usr/local/lib/python3.4/turtledemo/__init__.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/__main__.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/bytedesign.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/chaos.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/clock.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/colormixer.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/forest.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/fractalcurves.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/lindenmayer.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/minimal_hanoi.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/nim.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/paint.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/peace.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/penrose.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/planet_and_moon.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/round_dance.py'...
Compiling '/usr/local/lib/python3.4/turtledemo/tree.py'...
...........................................................................

To check the Python version, use the following command –

$ sudo python3.4 -V

The sample output should be like this –

Python 3.4.4

Congratulations! Now, you know “How to Install Python 3.4.4 on Ubuntu”. We’ll learn more commands in our next Linux post. Keep reading!

raja
Published on 22-Jan-2020 11:39:04
Advertisements
役に立ちましたか?
所属していません Tutorialspoint
scroll top