创建虚拟环境: Ansible, Python3, and Virtualenvs on CentOS and RHEL and MacOS

要为ansible运行创建一个最新的虚拟环境, 以下是步骤: 下载最新的python3.8.3安装包:

解压:

创建虚拟环境目录: mkdir /root/.python_env 编译安装python

配置一下pip国内源, 以增加安装速度

安装virtualenvwrapper

安装过程中报错: ImportError: No module named ‘_ctypes’, 解决方法是(参考https://stackoverflow.com/questions/27022373/python3-importerror-no-module-named-ctypes-when-using-value-from-module-mul):

然后重新编译安装python3 定义环境变量

  创建ansible虚拟环境:

  The prompt change tells us we’ve successfully made, and activated, our first python 3 virtualenv. Validate it is configured as Read more…