linux install miniconda
-
download miniconda
-
View system digits:
uname --m
Tsinghua source to view the corresponding version: https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/
-
Download wget:
apt-get update apt-get -y install wget
-
Download using the wget command:
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-py39_4.12.0-Linux-x86_64.sh
-
-
Install miniconda:
bash Miniconda3-py39_4.12.0-Linux-x86_64.sh
-
Add miniconda to environment variables:
Download vim:
apt-get -y install vim
vim ~/.bashrc
Add to:
export PATH="~/miniconda3/bin:"$PATH
source ~/.bashrc
source activate
-
Configure Tsinghua source
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-related
Create a virtual environment:conda create -n [虚拟环境名] python=3.9
View existing virtual environments:conda env list
Activate the virtual environment:conda activate [虚拟环境名]
Delete the virtual environment:conda remove -n [虚拟环境名] --all
View the installed packages in the current environment:conda list
Export the package in the current environment:conda env export > environment.yml
Install the environment according to the exported package:conda env create -f environment.yml
Installation package:conda install [包名]
Install the downloaded package locally:conda install --use-local [包路径]
Reference: https://www.freesion.com/article/86891500741/
Uninstall the package in the current environment:conda uninstall 包名
Uninstall the packages in the specified virtual environment:conda remove --name $[虚拟环境名] $[包名]
View current mirrorconda config --show channels
restore default imageconda config --remove-key channels
Configure Tsinghua source image
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
jupyter-related
Install jupyterlab:conda install jupyterlab
Add the current environment to jupyter kernel:python -m ipykernel install --user --name=[环境名]
Check out the jupyter kernels that have been added:jupyter kernelspec list
Delete the specified jupyter kernel:jupyter kernelspec remove [环境名]
The server opens jupyter:
-
Generate password and copy:
jupyter-notebook password
-
vim 用户目录/.jupyter/jupyter_lab_config.py
-
Create a jupyter configuration file:
jupyter lab --generate-config
-
Modify the JupyterLab configuration file:
vim 用户目录/.jupyter/jupyter_lab_config.py
add the following contentc.NotebookApp.allow_root = True c.NotebookApp.ip = '0.0.0.0' c.NotebookApp.open_browser = False c.NotebookApp.password = '复制的密码' c.NotebookApp.port = 8888
-
Background process:
nohup jupyter lab --allow-root > jupyter.log 2>&1 &
If the server has a firewall: map to the local
ssh -N -f -L localhost:8899:localhost:8899 用户名@服务器ip
Under the m1 chip, install the x86 package
Create a new virtual environment, the Python architecture in this environment is x86, after translating and running
CONDA_SUBDIR=osx-64 conda create -n test
conda activate test
python -c "import platform;print(platform.machine())"
should output "x86_64"
conda env config vars set CONDA_SUBDIR=osx-64
make sure that conda commands in this environment use intel packages
conda deactivate
# Need to reactivate the virtual environment for the settings to take effect
conda activate test
echo "CONDA_SUBDIR: $CONDA_SUBDIR"
# Should output "CONDA_SUBDIR: osx-64"