Ubuntu 14 安装Python科学计算环境

数据分析入门
2016-11-16 16:14

目录

1. 安装Anaconda 环境(Python 2)

1.1 完整安装包( 大约400M)

wget https://repo.continuum.io/archive/Anaconda2-4.2.0-Linux-x86_64.sh
bash Anaconda2-4.2.0-Linux-x86_64.sh

1.2 最小安装包(大约20M)

wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh
bash Miniconda2-latest-Linux-x86_64.sh

2. 更新依赖包

conda update --all
conda list

3. 国内建议添加清华源,加速下载

conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
conda config --set show_channel_urls yes

4. 创建虚拟环境

conda create -n py2env python=2
# 激活环境
source activate py2env
# 退出环境
source deactivate

5. 在当前虚拟环境下安装所需包

conda install -n py2env pandas numpy matplotlib jupyter scikit-learn    

6. 添加Jupyter 密码

jupyter notebook --generate-config
# 激活环境
source activate py2env
# 开 Ipython Shell
ipython
# 输入
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
# 编辑配置文件
sudo nano ~/.jupyter/jupyter_notebook_config.py
# 编辑密码
c.NotebookApp.password = u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'  

7. 设置Nginx

sudo nano /etc/nginx/sites-available/jupyter.zhengweiyu.com

加入以下内容

upstream jupyter  {
  server 127.0.0.1:8081;
  server 127.0.0.1:8082;
}

server {
  listen       80;
  server_name  jupyter.zhengweiyu.com;
  location / {
    proxy_pass  http://jupyter;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }
}

8. 启动 Jupyter Notebook

# 建立 jupyter_start.sh, 加入以下内容
#!/bin/bash
source activate py2env
jupyter notebook --no-browser --ip=0.0.0.0 --port=8081

# 启动 Jupyter Notebook
./jupyter_start.sh
加载 Disqus 评论

© 版权所有 悟理 2013-2019
Powered By Jekyll & Semantic UI

Ubuntu 14 安装Python科学计算环境

数据分析入门
2016-11-16 16:14

目录

1. 安装Anaconda 环境(Python 2)

1.1 完整安装包( 大约400M)

wget https://repo.continuum.io/archive/Anaconda2-4.2.0-Linux-x86_64.sh
bash Anaconda2-4.2.0-Linux-x86_64.sh

1.2 最小安装包(大约20M)

wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh
bash Miniconda2-latest-Linux-x86_64.sh

2. 更新依赖包

conda update --all
conda list

3. 国内建议添加清华源,加速下载

conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
conda config --set show_channel_urls yes

4. 创建虚拟环境

conda create -n py2env python=2
# 激活环境
source activate py2env
# 退出环境
source deactivate

5. 在当前虚拟环境下安装所需包

conda install -n py2env pandas numpy matplotlib jupyter scikit-learn    

6. 添加Jupyter 密码

jupyter notebook --generate-config
# 激活环境
source activate py2env
# 开 Ipython Shell
ipython
# 输入
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
# 编辑配置文件
sudo nano ~/.jupyter/jupyter_notebook_config.py
# 编辑密码
c.NotebookApp.password = u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'  

7. 设置Nginx

sudo nano /etc/nginx/sites-available/jupyter.zhengweiyu.com

加入以下内容

upstream jupyter  {
  server 127.0.0.1:8081;
  server 127.0.0.1:8082;
}

server {
  listen       80;
  server_name  jupyter.zhengweiyu.com;
  location / {
    proxy_pass  http://jupyter;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }
}

8. 启动 Jupyter Notebook

# 建立 jupyter_start.sh, 加入以下内容
#!/bin/bash
source activate py2env
jupyter notebook --no-browser --ip=0.0.0.0 --port=8081

# 启动 Jupyter Notebook
./jupyter_start.sh
加载 Disqus 评论

© 版权所有 悟理 2013-2019
Powered By Jekyll & Semantic UI

Ubuntu 14 安装Python科学计算环境

数据分析入门
2016-11-16 16:14

目录

1. 安装Anaconda 环境(Python 2)

1.1 完整安装包( 大约400M)

wget https://repo.continuum.io/archive/Anaconda2-4.2.0-Linux-x86_64.sh
bash Anaconda2-4.2.0-Linux-x86_64.sh

1.2 最小安装包(大约20M)

wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh
bash Miniconda2-latest-Linux-x86_64.sh

2. 更新依赖包

conda update --all
conda list

3. 国内建议添加清华源,加速下载

conda config --add channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'
conda config --set show_channel_urls yes

4. 创建虚拟环境

conda create -n py2env python=2
# 激活环境
source activate py2env
# 退出环境
source deactivate

5. 在当前虚拟环境下安装所需包

conda install -n py2env pandas numpy matplotlib jupyter scikit-learn    

6. 添加Jupyter 密码

jupyter notebook --generate-config
# 激活环境
source activate py2env
# 开 Ipython Shell
ipython
# 输入
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'
# 编辑配置文件
sudo nano ~/.jupyter/jupyter_notebook_config.py
# 编辑密码
c.NotebookApp.password = u'sha1:67c9e60bb8b6:9ffede0825894254b2e042ea597d771089e11aed'  

7. 设置Nginx

sudo nano /etc/nginx/sites-available/jupyter.zhengweiyu.com

加入以下内容

upstream jupyter  {
  server 127.0.0.1:8081;
  server 127.0.0.1:8082;
}

server {
  listen       80;
  server_name  jupyter.zhengweiyu.com;
  location / {
    proxy_pass  http://jupyter;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
  }
}

8. 启动 Jupyter Notebook

# 建立 jupyter_start.sh, 加入以下内容
#!/bin/bash
source activate py2env
jupyter notebook --no-browser --ip=0.0.0.0 --port=8081

# 启动 Jupyter Notebook
./jupyter_start.sh
加载 Disqus 评论

© 版权所有 悟理 2013-2019
Powered By Jekyll & Semantic UI