python/conda environment configuration

1. anaconda navigator is stuck on the loading applications page when it is started

Open anaconda prompt as an administrator
Next, enter y when you encounter [y/n]

Upgrade Navigator: CONDA update Anaconda navigator
Reset Navigator: execute Anaconda navigator -- reset
Upgrade client: CONDA update Anaconda client
Upgrade installation dependency package: CONDA update - f Anaconda client
Open: Anaconda navigator

2. Create virtual environment

establish:
CONDA create - N scratch env (environment name) python=3.7.0
#Activate virtual environment
conda activate scrapy-env
#Install related packages
conda install XXX
pip install XXX
If you want to install in the specified environment
conda install -n your_env_name [package]
#Exit environment
deactivate
#Delete environment
conda remove -n your_ env_ Name (virtual environment name) -- all
conda remove --name your_env_name package_name # deletes a package in the environment

3. Conda replace domestic source

Windows users cannot directly create a file named. condarc. You can execute it first
conda config --set show_channel_urls yes
Generate the file. The generated file is in C:\Users \ username. condarc

ssl_verify: true
envs_dirs:
  - C:\ProgramData\Anaconda3\envs
pkgs_dirs:
  - C:\ProgramData\Anaconda3\pkgs
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
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
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/msys2
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/pro
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/r
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/free
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/main
  - https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/
  - https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
  - https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
  - https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
  - https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
  - defaults

4. Modify conda environment and cache default path

By default, the new environment created by conda and the previously installed module cache are stored in the user directory. This will not be reflected in the user name \. condarc of the conda (user specific) configuration file unless the user modifies the default setting. The current default information can be printed and viewed through the conda info instruction, which can not only view the current default environment path and default cache path, but also view the source settings of conda.
In fact, the default paths of conda environment and cache (envs directories and package cache) do not have to be stored in the user directory by default. We can set them to other directories with slightly larger surplus space to alleviate this space pressure, as long as we ensure that the settings are different among different users. The path can be set by editing the user name \. condarc. Add or modify env in user name \. condarc_ Dirs and Pkgs_ The dirs configuration item sets the environment and cache path respectively. The first path in order is used as the default storage path. When searching the environment and cache, it is found in each directory in order.

Keywords: Python Pycharm

Added by Xanza on Sun, 07 Nov 2021 23:49:50 +0200