conda creates a new environment (Jupyter)

Likes and attention are the biggest motivation for my creation~~

When we use Anaconda, in some cases, an initial environment is not enough. Installing all packages in one environment will also cause various errors such as incompatibility, so we can create a new In order to achieve different functions in different environments.

Insert picture description here

  1. Create and activate a new environment

conda create --name envName

NB: Replace envName with the environment name.
This creates a python environment that is the same as the current python version

See here for other python version requirements

  1. Install Jupyter Lab (only install in one environment, the base environment is very suitable, so there is no need to switch the default environment)
    conda install jupyterlab

  2. Install ipykernel

Make sure to switch to the new environment just created:
conda activate envName

Install ipykernel in this environment (NB: this is not to install Jupyter , just make it open with Jupyter):
conda install -c conda-forge ipykernel

Then, execute:
python -m ipykernel install --name envName

Now open Anaconda Prompt, enter jupyter lab, and open the page of Jupyter Lab, you can see the new environment! ! !

  1. Install other required packages, preferably the same channel (eg, conda-forge)
# 查看自己 conda 配置的channel,同时会显示优先级
conda config --get channels

# 添加 conda-forge 为最高优先级
conda config --prepend channels conda-forge
# 如果已经有 conda-forge, 并且优先级较低,则先 remove,再 prepend

# 设置好之后,就直接用 conda install '+ package' 就可以了,无需 conda install -c conda-forge '+ package'

Guess you like

Origin blog.csdn.net/qq_35762060/article/details/108908399