使用pyenv管理虚拟环境
安装Python所需的环境依赖
yum install -y gcc zlib-devel bzip2 bzip2-devel readline-devel sqlite sqlite-devel openssl-devel tk-devel libffi-devel xz-devel git
设置安装目录
$ vim /etc/profile.d/custom.sh # 设置目录 export PYENV_ROOT=/usr/local/pyenv # 执行生效 source /etc/profile.d/custom.sh
安装pyenv
curl https://pyenv.run | bash % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 270 100 270 0 0 43 0 0:00:06 0:00:06 --:--:-- 72 curl: (7) Failed connect to raw.githubusercontent.com:443; 拒绝连接 # 如果下载失败,直接使用浏览器打开 https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer 复制内容到文本保存 vim pyenv-installer.sh bash pyenv-installer.sh
安装spider-admin-pro
pip3 install spider-admin-pro # 如果报错可以尝试使用阿里云作为安装源 pip3 install spider-admin-pro -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com # 安装提示缺少的依赖 pip3 install flask_cors -i http://mirrors.aliyun.com/pypi/simple/ --trusted-host mirrors.aliyun.com