官术网_书友最值得收藏!

Installing Python

  1. If you are using a Debian-based distribution such as Ubuntu you can install Python with:
$ sudo apt-get install python

If your system runs CentOS/RHEL, use the following command to install Python:

$ sudo yum install python  

If it's a SuSE Linux distribution, use the following command to install Python:

$ sudo yum install python 
  1. Check the version of installed Python interpreter with the following command in the Terminal:
$ python -version  

This will print the current installed Python version.

  1. If you want to install a specific version of Python, we get the Python source code from the https://www.python.org/ website and install it manually. For this, you can download the required source archive from https://www.python.org/ftp/python/.

You can download with the following command; make sure to replace the version number with your required one:

$ wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tgz      
  1. Then we have to extract the downloaded archive with the following command:
$ tar -xvzf Python-3.6.2.tgz    

It will be extracted to a Python-3.6.2 folder.

  1. Now you can configure, build, and install Python, for this you need to have a C compiler installed on your system. If it's not installed you can do it as follows:
    • For Debian/Ubuntu:
$ sudo apt-get install gcc
    • For CentOs/ RHEL:
$ yum install gcc

Then, you can run configure for configuring the build and then install the build with the make altinstall command:

$ cd Python-3.6.2
$ ./configure --prefix=/usr/local
$ make altinstall  

After installation, you can see both versions of Python installed on the system and you can choose which version to use while running the scripts.

主站蜘蛛池模板: 华池县| 井研县| 鞍山市| 通化市| 无棣县| 永顺县| 平原县| 万安县| 陆河县| 黄石市| 嘉荫县| 曲阳县| 馆陶县| 美姑县| 利川市| 麻栗坡县| 杭锦后旗| 阿坝县| 石台县| 静海县| 宜宾市| 全南县| 邯郸县| 同德县| 遂宁市| 临西县| 阳信县| 栾城县| 伊川县| 朝阳区| 上高县| 寻甸| 虹口区| 郧西县| 库尔勒市| 灵宝市| 隆昌县| 十堰市| 武陟县| 兰州市| 尚志市|