安装python3
安装EPEL和IUS软件源
yum -y install epel-release
yum -y install https://centos7.iuscommunity.org/ius-release.rpm
安装python3.6,pip3,devel (python3相关都安装)
yum install python3
安装virtualenv创建python虚拟环境
pip3 install -U virtualenv
基本用法 virtualenv文档地址
https://www.bookstack.cn/read/virtualenv-zh/date-2018.08.27.08.08.23
# 创建环境
virtualenv venv # 创建虚拟环境venv可替换为你想要的环境名
# 激活环境
cd venv # 进入你创建的环境目录
source bin/activate # 激活环境
# 退出环境
deactivate
# 设置用py3创建环境-带参数 只在拥有全局site-packages目录的读写权限,并且你的应用要依赖其中的模块的情况下,该参数会很有用。其他情况下没必要使用该参数。 -p 指定python 版本
virtualenv --system-site-packages -p python3 ./tf_py3
source tf_py3/bin/activate # 激活环境
安装tensorflow2
进入激活环境后 确保pip版本高于19.0 直接安装就是2.0
#pip 镜像临时 阿里云镜像地址
pip install -i http://mirrors.aliyun.com/pypi/simple/ tensorflow
#永久修改 Linux下,修改 ~/.pip/pip.conf (没有就创建一个文件夹及文件。文件夹要加“.”,表示是隐藏文件夹)
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host = https://pypi.tuna.tsinghua.edu.cn
#保存 清华地址
pip install tensorflow
pip install numpy matplotlib sklearn pandas jupyter #安装相关库
安装jupyter notebook
#首次使用需要在命令行中运行 jupyter notebook --generate-config 才能生成“.jupyter”文件夹,根目录
jupyter notebook --generate-config
cd .jupyter
#vim jupyter_notebook_config.py 添加配置
#获取配置对象
#设置可访问ip
#打开时是否启动浏览器
#设置端口
#启动已有配置
c=get_config()
c.NotebookApp.ip="*"
c.NotebookApp.open_browser=False
c.NotebookApp.port=8085
c.NotebookApp.allow_remote_access=True
#运行
jupyter notebook
#填写token 设置密码