conda常用命令及jupyter配置

linux安装miniconda

  1. 下载miniconda

    1. 查看系统位数:uname --m

      清华源查看对应版本:https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/

    2. 下载wget:

    apt-get update
    apt-get -y install wget
    
    
    1. 利用wget命令下载:

      wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py39_4.12.0-Linux-x86_64.sh

  2. 安装miniconda:

    bash Miniconda3-py39_4.12.0-Linux-x86_64.sh

  3. 将miniconda添加到环境变量中:

    下载vim :apt-get -y install vim

    vim ~/.bashrc

    添加:export PATH="~/miniconda3/bin:"$PATH

    source ~/.bashrc

    source activate

  4. 配置清华源

    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/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
    conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
    conda config --set show_channel_urls yes
    

conda相关

创建虚拟环境:conda create -n [虚拟环境名] python=3.9
查看已有虚拟环境:conda env list
激活虚拟环境:conda activate [虚拟环境名]
删除虚拟环境:conda remove -n [虚拟环境名] --all
查看当前环境下已安装的包:conda list
导出当前环境下的包:conda env export > environment.yml
根据导出的包安装环境:conda env create -f environment.yml
安装包:conda install [包名]
安装下载到本地的包:conda install --use-local [包路径]

参考:https://www.freesion.com/article/86891500741/

卸载当前环境下包:conda uninstall 包名
卸载指定虚拟环境中的包:conda remove --name $[虚拟环境名] $[包名]
查看当前镜像conda config --show channels
还原默认镜像conda config --remove-key channels
配置清华源镜像
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/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes

pip镜像:pip install [包名] -i https://pypi.tuna.tsinghua.edu.cn/simple/

jupyter相关

安装jupyterlab:conda install jupyterlab
添加当前环境到jupyter kernel:python -m ipykernel install --user --name=[环境名]
查看已添加的jupyter内核:jupyter kernelspec list
删除指定jupyter内核:jupyter kernelspec remove [环境名]

服务器开jupyter:

  • 生成密码并复制:jupyter-notebook password

  • vim 用户目录/.jupyter/jupyter_lab_config.py

  • 创建jupyter配置文件:jupyter lab --generate-config

  • 修改JupyterLab配置文件:vim 用户目录/.jupyter/jupyter_lab_config.py
    添加下面的内容

      c.NotebookApp.allow_root = True
      c.NotebookApp.ip = '0.0.0.0'
      c.NotebookApp.open_browser = False
      c.NotebookApp.password = '复制的密码'
      c.NotebookApp.port = 8888
    
  • 后台运行:nohup jupyter lab --allow-root > jupyter.log 2>&1 &

服务器如果有防火墙:映射到本地

ssh -N -f -L localhost:8899:localhost:8899 用户名@服务器ip

在m1芯片下,安装x86的包

新建虚拟环境,该环境中的Python架构为x86,经过转译运行

CONDA_SUBDIR=osx-64 conda create -n test

conda activate test

python -c "import platform;print(platform.machine())"

应输出“x86_64”

conda env config vars set CONDA_SUBDIR=osx-64

make sure that conda commands in this environment use intel packages

conda deactivate # 需要reactivate该虚拟环境,以使设置生效

conda activate test

echo "CONDA_SUBDIR: $CONDA_SUBDIR" # 应输出“CONDA_SUBDIR: osx-64”

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值