擅长:python、mysql、java
<p>我不能标记为可能的重复,所以我只是粘贴在这里。如果这是错误的行为,我很抱歉:</p>
<p><a href="https://stackoverflow.com/questions/44490337/import-module-works-in-jupyter-notebook-but-not-in-idle">Import module works in Jupyter notebook but not in IDLE</a></p>
<p>原因是pythonidle无法访问<strong>pip/conda</strong>安装的库路径。必须将这些库路径添加到环境变量(PATH)中。为此,请打开“我的电脑”>;“属性”>;“高级系统设置”>;“系统”。在</p>
<p>在<strong>环境变量</strong>下查找<strong>路径</strong>,并在最后添加已安装库的位置。<a href="https://github.com/BurntSushi/nfldb/wiki/Python-&-pip-Windows-installation#python-install" rel="nofollow noreferrer">Refer this</a>获取有关如何在path变量中添加位置的详细信息。完成这些操作后,您就可以导入库了。为了知道python搜索哪些位置的库可以使用</p>
<pre><code>import sys
print sys.path
</code></pre>
<p>这将为您提供python搜索库的位置列表。编辑路径变量后,这些位置将反映在这里。在</p>
<p><a href="https://docs.python.org/2/using/windows.html" rel="nofollow noreferrer">Refer</a>这也是为了知道如何添加python库路径。在</p>
<p><strong>注意:</strong>本教程是关于如何编辑路径变量的参考。我建议您查找已安装库的位置,并按照步骤进行编辑。在</p>