Ubuntu下安装pyenv、IPython Notebook和科学计算包的过程总结

1.安装pip

1
2
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py
sudo python get-pip.py

2.如果没有装git,需要安装

1
sudo yum install git

3.安装python需要依赖的包

1
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

4.安装配置pyenv到具体目录
本次安装都是用 /pythontest

1
2
3
4
git clone https://github.com/yyuu/pyenv.git /pythontest/.pyenv
echo 'export PYENV_ROOT="/pythontest/.pyenv"' >> ~/.bashrc
echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc

重启shell,使改动生效

1
exec $SHELL

5.pyenv安装具体python版本

1
2
3
4
pyenv install 2.7.11 -v
pyenv install 3.5.1 -v
pyenv rehash
pyenv versions

6.安装pyenv-virtualenv

1
git clone https://github.com/yyuu/pyenv-virtualenv.git /pythontest/.pyenv/plugins/pyenv-virtualenv

其中/pythontest/.pyenv是你安装pyenv的目录
如果https不能使用,使用以下命令

1
git clone git://github.com/yyuu/pyenv-virtualenv.git /pythontest/.pyenv/plugins/pyenv-virtualenv

其中/pythontest/.pyenv是你安装pyenv的目录

1
exec "$SHELL"

重新加载shell,更新环境变量
7.创建3.5.1虚拟环境,所有都在这个环境下应用

1
pyenv virtualenv 3.5.1 env351

激活env351

1
pyenv activate env351

8.安装IPython所需依赖的包

1
sudo apt-get install g++

9.安装IPython及 IPython Notebook
pip install IPython
遇到错误,查阅pip install error #10454,运行apt-get install python-dev
安装IPython Notebook的依赖
pip install urllib3
10.安装科学计算所需的依赖

1
2
3
4
sudo apt-get install libfreetype6-dev
sudo apt-get install gfortran
sudo apt-get install libopenblas-dev liblapack-dev
sudo apt-get install libpng12-0 libpng12-dev

11.验证测试:
进入3.5.1环境,安装IPython Notebook

1
2
pyenv activate env351
pip install jupyter`

进入IPython notebook

1
2
3
jupyter notebook
```
退出3.5.1环境

pyenv deactivate
`

文章目录
|