一、Linux系统安装(编译)
1. 安装编译依赖包
$ yum install gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz-devel -y
2. 下载源码包
$ yum install lrzsz -y
$ rz
3. 解压
$ tar -zxvf Python-3.9.5.tgz
$ cd Python-3.9.5/
$ ls
aclocal.m4 config.sub* Doc/ install-sh* Mac/ Modules/ Parser/ Programs/ README.rst
CODE_OF_CONDUCT.md configure* Grammar/ Lib/ Makefile.pre.in netlify.toml PC/ pyconfig.h.in setup.py
config.guess* configure.ac Include/ LICENSE Misc/ Objects/ PCbuild/ Python/ Tools/
4. 编译&安装
$ mkdir /usr/local/python3
$ ./configure --prefix= /usr/local/python3 --with-ssl
$ make
$ make install
5. 使用python3
$ ln -s /usr/local/python3/bin/python3 /usr/local/bin/python3
$ ln -s /usr/local/python3/bin/pip3 /usr/local/bin/pip3
$ python3 --version
Python 3.9 .5
$ pip3 --version
pip 21.1 .1 from /usr/local/python3/lib/python3.9/site-packages/pip ( python 3.9 )
6. ipython
6.1 配置pip源
$ mkdir ~/.pip
$ vim ~/.pip/pip.conf
[ global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
trusted-host = pypi.tuna.tsinghua.edu.cn
6.2 install
$ pip3 install ipython
6.3 使用
$ ln -s /usr/local/python3/bin/ipython /usr/local/bin/
$ ipython
Python 3.9 .5 ( default, Jun 7 2021 , 07:45:38)
Type 'copyright' , 'credits' or 'license' for more information
IPython 7.24 .1 -- An enhanced Interactive Python. Type '?' for help.
In [ 1 ] : print( "你好,Python" )
你好,Python
二、Linux系统安装(yum)
1. 安装
$ yum install python36 python36-devel python3-tkinter -y
2. 使用
$ python3
Python 3.6 .8 ( default, Aug 7 2021 , 19 :28:30)
[ GCC 4.8 .5 20150623 ( Red Hat 4.8 .5-39) ] on linux
Type "help" , "copyright" , "credits" or "license" for more information.
>> >
3. pip源
$ mkdir ~/.pip
$ vim ~/.pip/pip.conf
[ global]
timeout = 6000
index-url = https://pypi.tuna.tsinghua.edu.cn/simple/
trusted-host = pypi.tuna.tsinghua.edu.cn
4. ipython
$ pip3 install ipython
$ ipython
Python 3.6 .8 ( default, Aug 7 2021 , 19 :28:40)
Type 'copyright' , 'credits' or 'license' for more information
IPython 7.9 .0 -- An enhanced Interactive Python. Type '?' for help.
In [ 1 ] : print( "你好,Python" )
你好,Python
三、Windows系统安装
1. 下载软件包
2. 安装
2.1 双击安装包,自定义安装
2.2 选择包,下一步
2.3 路径及功能选择
2.4 点击 install 安装
3. 使用
3.1 输入cmd,点击确定
3.2 使用python
3.3 输出:你好,Python