00-环境搭建
1.安装依赖包:
yum -y install gcc make patch gdbm-devel openssl-devel sqlite-devel readline-devel zlib-devel bzip2-devel
2.创建用户python
useradd python
3.使用python用户登录 下载pyenv
curl -L https://raw.githubusercontent.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash
curl -L https://raw.githubusercontent.com/pyenv/pyenv-installer/master/bin/pyenv-installer | bash
或
在python用户的 ~/.bash_profile 中追加如下内容:
export PATH="/home/python/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
source ~/.bash_profile
git clone https://github.com/pyenv/pyenv-virtualenv.git $(pyenv root)/plugins/pyenv-virtualenv
在python用户的 ~/.bash_profile 中追加如下内容:
eval "$(pyenv virtualenv-init -)"
source ~/.bash_profile
4.校验pyenv
pyenvpyenv help installpyenv install --listpyenv install 3.5.3pyenv versions
为了方便快速安装(通过使用缓存):
cd ~/.pyenv && mkdir cache
然后通过https://www.python.org/ftp/python/3.5.3/ 本地进行下载;将3.5.3 版本的安装包 下载下来 上传到 .pyenv/cache/ 下;然后 在执行 pyenv install 3.5.3
5.设置python 版本
pyenv global system (还原为最初)pyenv global 3.5.3 (全局的)pyenv shell 3.5.3 (会话级别,当前shell断开会有影响)pyenv local 3.5.3 (与文件夹/目录 绑定在一起)
6.独立空间(virtualenv)使用虚拟环境
cd ~/magedu/project/cmdbpyenv virtualenv 3.5.3 magedu353pyenv local magedu353
7.pip 配置
mkdir ~/.pipvim ~/.pip/pip.conf 内容如下:[global]index-url=https://mirrors.aliyun.com/pypi/simple/trusted-host=mirrors.aliyun.compip -V
安装ipython:pip install ipython安装 jupyter:pip install jupyter
启动 jupyter:
jupyter notebook --ip=0.0.0.0 --no-browser
jupyter notbook password (修改密码)
获取当前环境所安装的包情况:
pip freeze > requirement.txt
部署:
pip install -r requirement.txt
查询安装包:
pip search keyword关键字
8.更新 pyenv
cd ~/.pyenv && git pull
<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">

浙公网安备 33010602011771号