文章目录
- 安装python
- 安装conda
- 添加镜像源
- conda常见操作
- 安装Jupyter
- 切换到conda环境
- Markdown生成目录
- 安装rabbitmq
安装python
首先安装gcc编译器,gcc有些系统版本已经默认安装,通过 gcc --version 查看,没安装的先安装gcc
安装其它依赖包,(注:不要缺少,否则有可能安装python出错,python3.7.0以下的版本可不装 libffi-devel )
yum -y install gcc
yum -y install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel xz-devel libffi-devel
下载python,解压,安装
wget https://www.python.org/ftp/python/3.7.9/Python-3.7.9.tgz
tar -zxvf Python-3.7.9.tgz
mkdir /usr/local/python3
cd Python-3.7.9
./configure --prefix=/usr/local/python3
make && make install
ln -s /usr/local/python3/bin/python3.7 /usr/bin/python3
ln -s /usr/local/python3/bin/pip3.7 /usr/bin/pip3
测试是否可用
python3
pip3
或者直接—配置环境变量/etc/profile
设置一下路径
export PYTHON_HOME=/usr/local/python7
export PATH=$PYTHON_HOME/bin:$PATH
重载环境变量
source /etc/profile
可能出现的问题
#编译出现
If you want a release build with all stable optimizations active (PGO, etc),
please run ./configure --enable-optimizations
运行下面命令进行配置优化
./configure --enable-optimizations
安装完成没有提示错误便安装成功了
最后发现都安装到/usr/local里面了,没有安装到/usr/local/python3里面,
应该是执行./configure --enable-optimizations时候重新编译了,这里也需要加目录
./configure --enable-optimizations --prefix=/usr/local/python3
安装conda
wget -c https://repo.anaconda.com/archive/Anaconda3-2021.04-Linux-x86_64.sh
chmod 775 Anaconda3-2021.04-Linux-x86_64.sh
bash Anaconda3-2021.04-Linux-x86_64.sh
配置环境变量/etc/profile.在末尾出添加
export PATH=$PATH:/root/anaconda3/bin
/root/anaconda3/bin 是我anaconda的安装路径
重载环境变量
source /etc/profile
验证是否安装成功,重新打开的终端输入以下命令
conda --version
安装完后,新版的Anaconda会在每一个新开的terminal里面自动进入虚拟环境base,解决方法是用conda config命令:
conda config --set auto_activate_base false
添加镜像源
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://anaconda.mirrors.sjtug.sjtu.edu.cn/pkgs/main
conda config --add channels https://anaconda.mirrors.sjtug.sjtu.edu.cn/pkgs/free
conda config --add channels https://anaconda.mirrors.sjtug.sjtu.edu.cn/pkgs/mro
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
centos可以安装
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/
windows请添加如下路径
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/
镜像源查看
conda config --show-sources
查看源地址:
conda config --show channels
删除所有的镜像源
conda config --remove-key channels
可能出现的问题
以下是windows出现的问题
结果出现了“CondaHTTPError: HTTP 000 CONNECTION FAILED for url https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/current_repodata.json”。以下是我的解决步骤。
进入”C:\Users\Administrator“,打开“.condarc“,你将会看到以下代码:
ssl_verify: true
show_channel_urls: true
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
修改文件
ssl_verify: true
show_channel_urls: true
channels:
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/win-64/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/
你也可能会在channels:下面看到 ”- default“,请删除它
点击保存
conda create -n joker python=3.7
conda常见操作
- 创建环境
conda create -n joker python=3.7
检查更新当前conda
conda update conda
- 查看环境名
conda env list
conda info --envs
- 查看安装的包名
conda list
- 激活环境
conda activate joker
退出环境
conda deactivate joker
有的时候是下面的这样子的
activate joker
退出环境
deactivate joker
linux中是这样子的
source activate your_env_name
- 删除虚拟环境
conda remove -n your_env_name(虚拟环境名称) --all
- 删除环境中的某个包。
conda remove --name your_env_name package_name
安装Jupyter
前提–安装了python
下载安装
pip install -i https://pypi.douban.com/simple jupyter
生成配置文件
jupyter notebook --generate-config --allow-root
结果如下
[root@instance-a78cuufh Python-3.7.9]# jupyter notebook --generate-config --allow-root
Writing default config to: /root/.jupyter/jupyter_notebook_config.py
设置密码
jupyter notebook password
修改配置文件
添加工作目录
mkdir /root/jupyter
命令修改
sed -ie "s/# c.NotebookApp.ip = 'localhost'/c.NotebookApp.ip = '0.0.0.0'/g" ~/.jupyter/jupyter_notebook_config.py
sed -ie 's/# c.NotebookApp.port = 8888/c.NotebookApp.port = 8000/g' ~/.jupyter/jupyter_notebook_config.py
sed -ie 's/# c.NotebookApp.open_browser = True/c.NotebookApp.open_browser = False/g' ~/.jupyter/jupyter_notebook_config.py
sed -ie 's/# c.NotebookApp.allow_password_change = False/c.NotebookApp.allow_password_change = True/g' ~/.jupyter/jupyter_notebook_config.py
sed -ie 's/# c.NotebookApp.allow_remote_access = False/c.NotebookApp.allow_remote_access = True/g' ~/.jupyter/jupyter_notebook_config.py
sed -ie 's/# c.NotebookApp.allow_origin = ''/c.NotebookApp.allow_origin = \'*\'/g' ~/.jupyter/jupyter_notebook_config.py
sed -ie 's/# c.NotebookApp.notebook_dir = ''/c.NotebookApp.notebook_dir = \'/root/jupyter/\'/g' ~/.jupyter/jupyter_notebook_config.py
解释如下
# 设置监听地址,一般改为当前主机的ip
sed -ie "s/# c.NotebookApp.ip = 'localhost'/c.NotebookApp.ip = '0.0.0.0'/g" ~/.jupyter/jupyter_notebook_config.py
# 设置监听端口
sed -ie 's/# c.NotebookApp.port = 8888/c.NotebookApp.port = 8000/g' ~/.jupyter/jupyter_notebook_config.py
# 禁用自动打开浏览器
sed -ie 's/# c.NotebookApp.open_browser = True/c.NotebookApp.open_browser = False/g' ~/.jupyter/jupyter_notebook_config.py
# 禁止随意修改密码
sed -ie 's/# c.NotebookApp.allow_password_change = False/c.NotebookApp.allow_password_change = True/g' ~/.jupyter/jupyter_notebook_config.py
# 是否允许远程访问
sed -ie 's/# c.NotebookApp.allow_remote_access = False/c.NotebookApp.allow_remote_access = True/g' ~/.jupyter/jupyter_notebook_config.py
# Nginx访问时会出现跨域访问,需要在这里允许
sed -ie "s/# c.NotebookApp.allow_origin = ''/c.NotebookApp.allow_origin = '*'/g" ~/.jupyter/jupyter_notebook_config.py
# 工作目录
sed -ie "s/# c.NotebookApp.notebook_dir = ''/c.NotebookApp.notebook_dir = '/root/jupyter/'/g" ~/.jupyter/jupyter_notebook_config.py
手动修改
# Nginx访问时会出现跨域访问,需要在这里允许
c.NotebookApp.allow_origin = '*'
# 禁止随意修改密码
c.NotebookApp.allow_password_change = False
# 是否允许远程访问
c.NotebookApp.allow_remote_access = True
# IP
c.NotebookApp.ip = '0.0.0.0'
# 端口
c.NotebookApp.port = 8000
# 工作目录
c.NotebookApp.notebook_dir = '/root/jupyter/'
# 启动Jupyter Notebook之后是否打开浏览器
c.NotebookApp.open_browser = False
- ip设置为0.0.0.0,可以保证局域网内其他用户访问;
- 端口设置为9820,默认为8888,也可以为其他,但要保不发生端口占用;
- 工作目录自定义设置,含义为jupyter noteboo启动时的默认工作目录;
- 密码哈希值为设置登录密码时自动生成的。
启动
项目启动有两种方式:
- 直接启动
终端输入命令:
jupyter-notebook --allow-root
该方式的好处是可以在终端实时查看jupyter界面操作,即日子实时打印的功能。缺点是终端退出,服务就终止了。
- 后台启动
终端输入命令:
nohup jupyter notebook --allow-root &
关闭
可能出现的问题
打开或者new .ipynb文件时报错:
sudo chmod 777 ~/.local/share/jupyter/
cd ~/.local/share/jupyter/
sudo chmod 777 runtime/
# 重启Jupyter
切换到conda环境
安装Anaconda
安装插件
conda install nb_conda
切换到conda环境中
Linux&mac环境:
source activate your_env_name
Windows:
conda activate your_env_name
在虚拟环境中安装jupyter
conda install -y jupyter
Markdown生成目录
conda install -c conda-forge jupyter_contrib_nbextensions
执行上述命令后,启动Jupyter Notebook,你会发现导航栏多了“Nbextensions”的类目,点击“Nbextensions”,勾选“Table of Contents ⑵”
nbextensions
之后再在Jupyter Notebook中使用Markdown,点击下图的图标即可使用啦。
安装rabbitmq
yum update
yum install epel-release
yum install erlang
yum install rabbitmq-server
rabbitmq-plugins enable rabbitmq_management
systemctl start rabbitmq-server
rabbitmq安装stomp
rabbitmq-plugins enable rabbitmq_stomp
rabbitmq-plugins enable rabbitmq_web_stomp
systemctl restart rabbitmq-server