python3安装及配置环境变量+/etc/profile和/root/.bash_profile区别

1、依赖包安装

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 libffi-devel

2、下载包:

wget https://www.python.org/ftp/python/3.8.1/Python-3.8.1.tgz

3、解压:

tar -zxvf Python-3.8.1.tgz

4、安装:

cd Python-3.8.1
./configure --prefix=/usr/local/python3
make && make install

5、建立软连接

ln -s /usr/local/python3/bin/python3.8 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.8 /usr/bin/pip3
配置环境变量

主要是能快速使用pip安装命令

执行 vi ~/.bash_profile,打开配置文件,添加如下配置:

#配置python
export PYTHON_HOME=/root/training/Python-3.6.5
export PATH=$PYTHON_HOME/bin:$PATH**

保存退出(:wq),执行source ~/.bash_profile命令使配置生效。

执行echo命令,查看是否配置成功,如:

echo $PYTHON_HOME
/etc/profile和/root/.bash_profile区别
  • /etc/profile,优先级最高,是全局的,是私有的,用于整个系统所有用户
  • ~/.bashrc和 ~/.bash_profile, ~/.profile 用于各个用户,这里的"~"符号就是各当前用户的$HOME
  • ~/.bash_profile 和 ~/.profile 只在登陆时读取一次
  • ~/.bashrc 每次都读取
~/.bash_profile 和 ~/.profile 的区别在于
  • bash 只读取~/.bash_profile;而对于 ~/.profile 来说,不光bash, 其他shell 也读 ~/.profile

参考:
https://www.jb51.net/article/184282.htm

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值