关于python的环境配置

关于python

Windows中python的安装

安装完成后,按下win+R ,输入cmd进入命令行

输入python --version可以查看是否安装(或者python -V)

输入python进入命令行后,可以输入quit()退出当前模式

image-20211006090407579

Linux中python的安装

#输入以下文字安装python
[root@localhost ~]# yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel

image-20211006182829890

可以提前准备python安装包

进入/opt目录

[root@localhost ~]# cd /opt

#将提前下好的python包拖入(可以去官网下),或者输入

[root@localhost opt]# wget http://npm.taobao.org/mirrors/python/3.9.0/Python-3.9.0.tgz

image-20211006183019680

#如果没有wget命令,输入yum -y install wget,安装

image-20211006183129454

安装python3
1.创建目录
[root@localhost opt]# mkdir -p /usr/local/python3

2.解压

[root@localhost opt]# tar -zxvf Python-3.9.0.tgz

image-20211006183246155

3.安装gcc包
[root@localhost opt]# yum install gcc
image-20211006183315688

4.安装libffi-devel包

[root@localhost opt]# yum install libffi-devel -y

image-20211006183358051

5.[root@localhost opt]# cd Python-3.9.0/

6.[root@localhost Python-3.9.0]# ./configure --prefix=/usr/local/python3

image-20211006183534554

7.编译

[root@localhost Python-3.9.0]# make

image-20211006183720560

8.编译完成后安装

[root@localhost Python-3.9.0]# make install

image-20211006183804928

9.检查

[root@localhost Python-3.9.0]# /usr/local/python3/bin/python3

image-20211006183913863

10.[root@localhost Python-3.9.0]# vim /etc/profile #复制以下内容


# .bash_profile

# Get the aliases and functions

if [ -f ~/.bashrc ]; then

. ~/.bashrc

fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin:/usr/local/python3/bin

export PATH

image-20211006184922775

Esc,:wq 保存退出

[root@localhost Python-3.9.0]# source /etc/profile

12.验证

[root@localhost Python-3.9.0]# python3 -V

[root@localhost Python-3.9.0]# pip3 -V

image-20211006185018237

[root@localhost Python-3.9.0]# python3

python安装完成

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值