建立 Python 虚拟环境,,1.1 安装依赖包$


1.1 安装依赖包

$ yum -y install wget gcc epel-release git

1.2 安装 Python3.6和pip

$ yum -y install python36 python36-devel
$ curl https://bootstrap.pypa.io/get-pip.py |python3.6

1.3 建立 Python 虚拟环境

因为 CentOS 6/7 自带的是 Python2,而 Yum 等工具依赖原来的 Python,为了不扰乱原来的环境我们来使用 Python 虚拟环境

$ cd /opt$ python3.6 -m venv py3$ source /opt/py3/bin/activate

# 看到下面的提示符代表成功,以后运行 Jumpserver 都要先运行以上 source 命令,以下所有命令均在该虚拟环境中运行
(py3) [root@localhost py3]

1.4 自动载入 Python 虚拟环境配置

此项仅为懒癌晚期的人员使用,防止运行 Jumpserver 时忘记载入 Python 虚拟环境导致程序无法运行。使用autoenv

$ cd /opt$ git clone https://github.com/kennethreitz/autoenv.git$ echo ‘source /opt/autoenv/activate.sh‘ >> ~/.bashrc$ source ~/.bashrc

建立 Python 虚拟环境

评论关闭