当前位置: 首页 > 工具软件 > pyenv > 使用案例 >

pyenv

田慈
2023-12-01

1. pyenv的安装

1.1 安装curl与git:

sudo apt-get update
sudo apt-get install curl git-core

1.2 安装pyenv

curl -L https://raw.github.com/yyuu/pyenv-installer/master/bin/pyenv-installer | bash

1.3 修改~/.bashrc

vim ~/.bashrc
# pyenv
export PYENV_ROOT="${HOME}/.pyenv"
if [ -d "${PYENV_ROOT}" ]; then
  export PATH="${PYENV_ROOT}/bin:${PATH}"
  eval "$(pyenv init -)"
  eval "$(pyenv virtualenv-init -)"
fi
source ~/.bashrc

或者

export PATH="/home/hgw/.pyenv/bin:$PATH"
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"

2. 安装依赖

sudo apt-get install libbz2-dev
sudo apt-get install libsqlite3-dev 
sudo apt-get install libssl-dev
sudo apt-get install build-essential
sudo apt-get install -y make cmake

sudo apt-get install -y zlib1g-dev libreadline-dev wget llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev

sudo apt-get install -y make build-essential libssl-dev zlib1g-dev libbz2-dev \
libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev \
xz-utils tk-dev libffi-dev liblzma-dev python-openssl git
sudo apt install libedit-dev

3. 安装python版本

pyenv install --list
pyenv install 2.7.15
pyenv virtualenv 2.7.15 env2715

4. 安装开发框架

pyenv activate env2715
pip install tensorflow-gpu==1.4     # gpu
# pip install tensorflow==1.4       # cpu
pip install keras==2.13

5. 切换全局环境

pyenv global 2.7.15
pyenv global system

6. 卸载

pyenv uninstall 2.7.15
rm -rf /home/hgw/.pyenv/versions/2.7.15/envs/env2715
 类似资料: