您的位置:首页 > 运维架构 > Linux

centos7 和ubuntu下搭建 jupyter notebook,配置R环境

2018-01-21 13:02 956 查看
更简单的安装方法:
下载anaconda,这是一个包含很多常用科学计算的包,不用自己再重新安装了
在目录下sh xx.sh剩下的就简单了,同意协议等
然后就安装好了,如果输入conda 提示报错的话可以:source /root/.bashrc使写入环境变量的文件生效
如果是服务器上的话可以输入ipython:In [1]: from notebook.auth import passwd

In [2]: passwd()
Enter password:
Verify password:
Out[2]: 'sha1:64341aa9b492:97596b3b.....58e145261ca4f9562158a581b'复制下生成的密文
然后yum install vim

jupyter notebook --generate-config

sudo vim /root/.jupyter/jupyter_notebook_config.py在配置文件里最后一行加入c.NotebookApp.ip = '*'

c.NotebookApp.password = u'' #输入刚刚复制的密文
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888允许8888这个端口可以访问/sbin/iptables -I INPUT -p tcp --dport 8888 -j ACCEPT然后输入jupyter notebook或者把启动文件写入脚本中或者直接输入下面的这行,后台运行jupyter notebook >/dev/null 2>&1 &配置R环境conda install r r-essentials

下面的是以前的方法,大家随便看看吧……

安装jupyterpip3 install jupyter
配置jupyter notebook
创建目录/root/notebook/jupyter/root作为jupyter notebook的根目录
终端输入ipython,获得notebook加密后的密码
from IPython.lib import passwd
passwd() #得到加密后的hash
exit生成配置文件
jupyter notebook --generate-config
vim ~/.jupyter/jupyter_notebook_config.py配置jupyter_notebook_config.py
c.NotebookApp.ip = '*'
c.NotebookApp.allow_root = True
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888
c.NotebookApp.password = u'sha1:...' #输入上面加密后得到的密文
c.ContentsManager.root_dir = '/root/notebook/jupyter/root' #上面创建的目录运行
jupyter notebook后台运行
nohup jupyter notebook > /root/notebook/jupyter/jupyter.log 2>&1 &
如果无法运行可能是端口不允许访问
iptables -I INPUT -p tcp -m state --state NEW -m tcp --dport 8888 -j ACCEPT
安装matplotlib模块
pip3 install matplotlib使用时使用在cell中要先输入
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

x = np.arange(-10, 11)
y = x**2

plt.plot(x, y)
plt.show()


from numpy.random import beta
import matplotlib.pyplot as plt

plt.style.use('bmh')

def plot_beta_hist(ax, a, b):
ax.hist(beta(a, b, size=10000), histtype="stepfilled",
bins=25, alpha=0.8, normed=True)

fig, ax = plt.subplots()
plot_beta_hist(ax, 10, 10)
plot_beta_hist(ax, 4, 12)
plot_beta_hist(ax, 50, 12)
plot_beta_hist(ax, 6, 55)
ax.set_title("'bmh' style sheet")

plt.show()


import random

import numpy as np
import matplotlib.pyplot as plt
from mat
bac5
plotlib import cm
from mpl_toolkits.mplot3d import Axes3D

X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)

fig = plt.figure()
ax = Axes3D(fig)
ax.plot_surface(X, Y, Z, rstride=1, cstride=1, cmap=cm.viridis)

plt.show()



安装tensorflow模块
pip3 install protobuf
pip3 install tensorflow
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐