Jupyter notebook uses the conda virtual environment to report an error

introduce

First use Anaconda to create a virtual environment named pt37, and then want to open jupyter in this virtual environment.

According to other tutorials on the Internet conda install nb_conda, python -m ipykernel install --name {你的虚拟环境名字,如qq} --display-name {你想显示的名称}I did not find the created virtual environment in my own jupyter using and

And there will be various error reports:

  • conda install nb_condaProblems during installation:
ERROR conda.core.link:_execute(699): An error occurred while installing package 'http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main::nb_conda_kernels-2.3.1-py38haa95532_0'.
Rolling back transaction: done

LinkError: post-link script failed for package http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main::nb_conda_kernels-2.3.1-py38haa95532_0
location of failed script: D:\Anaconda\Scripts\.nb_conda_kernels-post-link.bat

insert image description here

  • python -m ipykernel install --name {你的虚拟环境名字,如qq} --display-name {你想显示的名称}Problems when installing with
(pt37) C:\Users\19631>python -m ipykernel install --user --name pt37 --display-name pt37
Installed kernelspec pt37 in C:\Users\19631\AppData\Roaming\jupyter\kernels\pt37

(pt37) C:\Users\19631>jupyter notebook
Cannot open D:\Anaconda\envs\pt37\Scripts\jupyter-notebook-script.py

insert image description here

So I thought about installing another jupyter directly in the virtual environment

Jupyter and ipykernel have been installed in the pt37 virtual environment and can be installed
directly using conda install jupyterand . If an error is reported during jupyter installation, you can use to install.conda install ipykernelpip install jupyter

When I use conda to install, the following error will appear:
Normal installation process
Error message:

ChecksumMismatchError: Conda detected a mismatch between the expected content and downloaded content
for url 'http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch/jupyter_console-6.4.0-pyhd3eb1b0_0.conda'.
  download saved to: D:\Anaconda\pkgs\jupyter_console-6.4.0-pyhd3eb1b0_0.conda
  expected sha256: d925edd3ae53456716abcd422b73ecedc610f78f17e53f3feb693f98e75918fc
  actual sha256: 53dffa149d7cfc4c9cc5638cbbbec1c1aabd84b0781299c27f5e1b382da46ee0

ChecksumMismatchError: Conda detected a mismatch between the expected content and downloaded content
for url 'http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/win-64/notebook-6.4.6-py37haa95532_0.conda'.
  download saved to: D:\Anaconda\pkgs\notebook-6.4.6-py37haa95532_0.conda
  expected sha256: 510268efd0828bba6afe4241a15f8a0287469e37d5d03d70511f4dc00eeabf0a
  actual sha256: 53dffa149d7cfc4c9cc5638cbbbec1c1aabd84b0781299c27f5e1b382da46ee0

error message
So using pip to install will be successful
pip install
The installation is successful, and the environment contains jupyter
pip installed successfully

further major issues

So can you happily open jupyter? ? Ah, no, there is still a problem, and this problem is a problem nb_condathat occurred ,
that is, "nb_conda_kernels. It cannot be opened in the terminal mode.
However, at the instigation of my friends, I uninstalled conda and reinstalled it, so that everything became the initial appearance, and then I thought of using jupyter in a virtual environment, so that I can continue to use jupyter later

error message

[C 09:52:54.885 NotebookApp] Bad config encountered during initialization: The 'kernel_spec_manager_class' trait of <notebook.notebookapp.NotebookApp object at 0x000002B09C38E808> instance must be a type, but 'nb_conda_kernels.CondaKernelSpecManager' could not be imported

insert image description here
Solution
I installed jupyter in the virtual environment, but there is no way to open it, so try to see if the jupyter in the main environment can still be used. After all, I installed two jupyters
insert image description here
! ! ! It works, thank goodness! ! !
Then look at how the kernel
jupyter
turned out to be a success! ! !

Although I don’t know how it succeeded, I stepped on a lot of pitfalls along the way, including uninstalling and reinstalling, so I will briefly write down the problems I encountered, hoping to help everyone. I have been groping, and I hope you can share with me if you have any questions!

Guess you like

Origin blog.csdn.net/m0_56075892/article/details/121553907