White scratch to learn programming environment to build and install --python

Foreword

From the beginning in March 2020, plans to write a series of documents - "white learn programming from scratch" to record some of the things they learn from zero.

  • The first series: python, plans to install, set up the environment, basic grammar, to use Django and Flask two current hottest web framework to complete a small project
  • Second series: Go may choose the language, may also choose Vue.js. Specific circumstances to be determined, it remains to be seen. . .

python Installation and Configuration

python2 began in early 2020 is no longer maintained, so learning only discuss python3

windows environment

Download the installation package python3

To the official website to choose the right windows version can, https://www.python.org/downloads/windows

  • I'm here to install the latest stable version python3.8 examples to look at
    downloading binary executable file
start installation

Once downloaded, simply double-click to open, start the installation, start checking the best first step in adding environment variables, or need to manually add your own , you can choose to install on the C drive

The third step is to confirm installation

After waiting for the completion of the installation, the CMD is opened, the python command input window is displayed as shown below to explain successfully installed.


mac environment

mac computer to install everything with brew, mac computer python2 bring their own version of the interpreter

The first step, the installation configuration homebrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

The second step, the installation python3

Enter the following command, patiently wait for the installation to complete
brew install python3

The third step is to verify that the installation was successful

python3
If you do not prompt command is not available to
mac installation not need to configure the default python interpreter
* * *

Linux environment

How Linux Centos the company of the most common installation operation

Centos

  • Linux systems generally comes python2, need to manually install version python3
The first step, download the installation package, or in the 3.8.2 version, for example, enter the following command in turn, quietly waiting for installation on it!

cd /usr/local # 将安装包下载到/usr/local目录下,并安装在此目录 wget https://www.python.org/ftp/python/3.8.2/Python-3.8.2.tar.xz


安装编译工具 yum install gcc-c++ gcc make cmake zlib-devel bzip2-devel openssl-devel ncurse-devel libffi-devel -y

The second step, unzip the package, compile and install
# 解压包
tar -xvf Python-3.8.2.tar.xz   

mv Python-3.8.2 Python3.8
cd Python3.8
./configure
make && make instal
The third step is to verify the installation
# 输入命令
python3

显示如下图则表示安装成功

第四步,将python3 设置为默认python解释器
# 备份python2
mv /usr/bin/python /usr/bin/python.bak
# 设置软连接,将python3指定到/usr/bin/目录下
ln -s /usr/local/bin/python3.8 /usr/bin/python
第五步,解决yum不可用的问题

分别执行以下命令,将/usr/bin/python改为/usr/bin/python2.7

vim /usr/bin/yum

vim /usr/libexec/urlgrabber-ext-down

结果如图所示:


结束语

万里长征走过了第一步,相信看完这篇文章只要舍得动手,你一定可以搭建一个正确的开发环境。
下一篇将介绍一下python的虚拟环境管理,敬请期待。。。

Guess you like

Origin www.cnblogs.com/codeBang/p/12430169.html