擅长:python、mysql、java
<p>很可能,当您启动笔记本时,您加载了错误的内核。
以下是设置环境的基本方法:</p>
<pre><code>conda create -n testenv python=3.7 -y
conda activate testenv
conda install scikit-learn
conda install ipython
conda install notebook
python -m ipykernel install --user --name testenv
</code></pre>
<p>当您在浏览器中单击<code>new</code>时,python3旁边会有一个附加选项,即刚刚注册的内核。我刚用Anaconda4.7测试了这个,我可以导入sklearn。在</p>
<h3>编辑:</h3>
<p>答案中的代码创建了一个新的python环境。然后,它在该环境中安装ipython和jupyter notebook,并确保该环境可以与jupyter notebook一起使用(即注册ipykernel)。在</p>
<p>当然,除了scikitlearn之外,没有其他库安装在这个特定的环境中。在</p>
<p>因此,如果要使用更多库,则必须转到命令行,激活环境,然后安装要使用的库:</p>
^{pr2}$
<p>要从环境中运行jupyter notebook,在您安装了所需的所有东西(关闭命令提示符或停用环境之后),您可以</p>
<pre><code>conda activate testenv
jupyter notebook
</code></pre>
<p>在命令提示符下。在</p>