擅长:python、mysql、java
<p>我正面临着这个问题。结果发现它使用的是系统Python版本,尽管我已经激活了虚拟环境。</p>
<p>这就是最终成功的原因。</p>
<p>如果您使用的虚拟环境的名称为<code>myvenv</code>,请首先使用命令激活它:</p>
<pre><code>source activate myenv
</code></pre>
<p>然后使用以下命令安装模块<code>ipykernel</code>:</p>
<pre><code>pip install ipykernel
</code></pre>
<p>最后运行(将下面代码中的myenv更改为环境名称):</p>
<pre><code>ipykernel install --user --name myenv --display-name "Python (myenv)"
</code></pre>
<p>现在重新启动笔记本,它将在虚拟环境中使用Python版本。</p>