查看centOS版本:
cat /proc/version
查看Linux版本:
cat /etc/issue(仅适用于linux)
详见https://www.cnblogs.com/technicianafei/p/13793445.html
1.安装依赖,下载python3.7
# 1、yum更新yum源
yum update
# 2、安装Python 3.7所需的依赖否则安装后没有pip3包
yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel libffi-devel gcc make
# 3、在官网下载所需版本,这里用的是3.7.0版本
wget https://www.python.org/ftp/python/3.7.0/Python-3.7.0.tgz
2.安装python
# 1、解压
tar -zxvf Python-3.7.0.tgz
#2、配置编译
cd Python-3.7.0
./configure --prefix=/usr/local/python3 # 配置编译的的路径(这里--prefix是指定编译安装的文件夹)
./configure --enable-optimizations # 执行该代码后,会编译安装到 /usr/local/bin/ 下,且不用添加软连接或环境变量
make && make install
ln -s /usr/local/python3/bin/python3 /usr/bin/python3 # 添加软连接
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip3
#3、将/usr/local/python3/bin加入PATH
[root@linux-node1 testProj] vim /etc/profile
#然后在文件末尾添加:
export PATH=$PATH:/usr/local/python3/bin
# 修改完后,还需要让这个环境变量在配置信息中生效,执行命令
[root@localhost Python-3.7.0] source /etc/profile
参考
https://blog.csdn.net/m0_49177610/article/details/107403796
https://blog.csdn.net/sl_world/article/details/108538295
1、安装jupyter
pip3 isntall jupyter
2、进入python环境
# 假设你已经进入了python
In [1]: from notebook.auth import passwd
In [2]: passwd()
Enter password: # 可直接按Enter回车键
Verify password: # 可直接按Enter回车键
Out[2]: 'sha1:f704b702aea2:01e2bd991f9c7208ba177b46f4d10b6907810927'
3、生成并编辑jupyter配置文件
jupyter notebook --generate-config
生成的config file在 /root/.jupyter/jupyter_notebook_config.py
vim /root/.jupyter/jupyter_notebook_config.py
配置内容如下,可在vim命令模式下输入类似 /App.ip来定位 到该配置项的位置
# 将ip设置为*,允许任何IP访问
c.NotebookApp.ip = '*'
c.NotebookApp.allow_root = True
# 这里的密码填写上面生成的密钥
c.NotebookApp.password = 'sha1:f704b702aea2:01e2bd991f9c7208ba177b46f4d10b6907810927'
# 禁止用host的浏览器打开jupyter
c.NotebookApp.open_browser = False
# 监听端口设置为8888或其他
c.NotebookApp.port = 8888
# 允许远程访问
c.NotebookApp.allow_remote_access = True
# jupyter notebook工作目录
c.ContentsManager.root_dir = '/root/notebook/'
Jupyter notebook启动命令:
jupyter notebook --allow-root
1、后台运行Jupyter(不挂起)
nohup 表示 no hang up, 就是不挂起, 即使终端退出, 也不会停止运行.
$ nohup jupyter notebook --allow-root > jupyter.log 2>&1 &
&表示后台运行, > 表示把标准输出写入jupyter.log中
ps:
$ ls > ls.txt #或者 ls–>ls.txt #把ls命令的运行结果保存到文件ls.txt中
说明: > 是把输出转向到指定的文件,如文件已存在的话也会重新写入,文件原内容不会保留;
>> 是把输出附向到文件的后面,文件原内容会保留下来
2、结束服务
如果想要退出该进程,则先打印出进程id,然后kill掉即可
ps -aux | grep jupyter(服务名称)
#或者
netstat -tunlp | grep 8888(服务端口号)
kill -9 <进程id>
docker run -it -p 8888:8888 NAME:LABEL /bin/bash
进入新的容器后,
启动之前标记好的start.sh脚本文件($ nohup jupyter notebook --allow-root > jupyter.log 2>&1 &),查看jupyter.log,启动成功即可,
即可远程访问ip:8888,输入之前设置的密码
vim + 文件:如果存在即打开,否则创建
vim linux.txt
cat -A 文件 可以显示所有的不可见字符
有时,xxx命令不存在时因为存在不可见特殊字符,最简单的方法是vim创建新的 .sh 文件,重新写命令
$ cat -A /tmp/testing.txt
安装grpcio 报错 No such file or directory: ‘c++‘: ‘c++‘
pip install --upgrade pip #更新pip即可