Anconda环境部署 1、创建文件夹,下载Anaconda
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.05-Linux-x86_64.sh
2、安装
chmod +x Anaconda3-2021.05-Linux-x86_64.sh
./Anaconda3-2021.05-Linux-x86_64.sh
1 2 3 4 5 6 7 8 9 10 Please, press ENTER to continue Please answer 'yes' or 'no' :' # 输入 yes 按 enter [/root/anaconda3] >>> /root/Anaconda # 设置安装目录(必须未存在的文件夹),直接enter就是默认的目录,显示在左边中括号那个 Unpacking payload ... #出现就是就是在安装了 by running conda init? [yes|no] # 是否初始化conda,这里一定要输入yes 不要直接按enter,因为默认是no 然后就安装完成了
打开~/.bashrc会看到这段配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 __conda_setup="$('/root/Anaconda/bin/conda' 'shell.bash' 'hook' 2> /dev/null) " if [ $? -eq 0 ]; then eval "$__conda_setup " else if [ -f "/root/Anaconda/etc/profile.d/conda.sh" ]; then . "/root/Anaconda/etc/profile.d/conda.sh" else export PATH="/root/Anaconda/bin:$PATH " fi fi unset __conda_setup
3、验证安装
1 2 3 4 source ~/.bashrcconda -V conda 4.10.1
4、取消默认自动进入base环境
1 2 conda config --set auto_activate_base false conda deactivate
5、配置清华镜像
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 conda config --set show_channel_urls yes channels: - defaults default_channels: - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2 custom_channels: conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
conda config --show
验证
开发环境配置 1、新建nlp
虚拟环境
1 conda create -n nlp python=3.6.8
Jupyter Lab环境搭建 1、安装jupyter lab
1 conda install jupyterlab
2、编辑配置信息
1 2 3 4 5 6 7 8 9 10 jupyter notebook --generate-config c.ServerApp.open_browser = False c.ServerApp.ip='*' c.ServerApp.allow_remote_access = True c.ServerApp.allow_root = True c.ServerApp.port = 8888 c.ServerApp.root_dir = '/jupyter/xuxingchen' c.ServerApp.password = ''
3、生成远程密码
1 2 3 from jupyter_server.auth import passwd; passwd()
4、使用conda的Python环境
1 2 3 4 5 6 7 8 9 10 11 12 13 conda install nb_conda_kernels { "CondaKernelSpecManager" : { "kernelspec_path" : "--user" , "name_format" : "{kernel} ({environment})" } } conda install -n 环境名称 ipykernel python -m ipykernel install --user --name 环境名称
5、多用户配置
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 source /root/Anaconda/etc/profile.d/conda.shconda activate base root_dir="/jupyter/" log_dir="/root/.jupyter/logs/" declare -A dicdic=([zl]=8888 [xj]=8889 [zgp]=8890 [xxc]=8891) if [ $1 == "all" ]then for dirname in ${!dic[*]} do (jupyter-lab --port=${dic[$dirname]} --notebook-dir=$root_dir$dirname ) > $log_dir$dirname .log 2>&1 & sleep 2 cat $log_dir$dirname .log echo "jupyter lab $dirname are running successfully" done else (jupyter-lab --port=${dic[$1]} --notebook-dir=$root_dir$1 ) > $log_dir$1 .log 2>&1 & sleep 3 cat $log_dir$1 .log echo "jupyter lab $1 is running successfully" fi if [ $1 == "all" ]then list=("zl" "xj" "zgp" "xxc" ) for dirname in ${!list[@]} do PID=$(pgrep -f dir =/jupyter/${list[$dirname]} ) if [ $PID ] then kill -n 15 $PID echo "已终止${list[$dirname]} $PID " else echo "未找到${list[$dirname]} 相关进程" fi done else PID=$(pgrep -f dir =/jupyter/$1 ) if [ $PID ] then kill -n 15 $PID echo "已终止$1 $PID " else echo "未找到$1 相关进程" fi fi
6、代码提示
① 先去Node官网下载安装包 ,解压安装到指定位置
1 2 3 4 5 6 7 8 9 10 sudo mkdir -p /usr/local/lib/nodejs sudo tar -xJvf node-xxx.tar.xz -C /usr/local/lib/nodejs vim ~/.profile export PATH=/usr/local/lib/nodejs/node-$VERSION -$DISTRO /bin:$PATH source ~/.profilenode -v
② 关闭所有jupyter进程
③ 激活base环境,安装jupyterlab-lsp插件
1 2 3 4 conda activate pip install jupyterlab-lsp pip install python-lsp-server[all] pip install nbclassic==0.2.8
④ 重启jupyter,看到左下角状态栏有✔Fully字样即为成功
⑤ 去除下划线纠错标识,工具栏 - Settings - Advanced Settings,开启json视图,添加下方键值对即可关闭:
1 { "ignoreMessagesPatterns" : [ ".*" ] }