Python 安装

一、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 使用
# 编译安装python需要手动添加链接
$ 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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值