简体   繁体   English

有时无法导入 NumPy

[英]Sometimes Unable to Import NumPy

When I work in Jupyter Notebooks everything works fine, and I can import numpy and pandas successfully.当我在 Jupyter Notebooks 中工作时,一切正常,我可以成功导入 numpy 和 pandas。 However, when I try to download the script and then run it in an editor such as PyCharm or Atom, I get an import error: no module named numpy, and the same for pandas.但是,当我尝试下载脚本然后在 PyCharm 或 Atom 等编辑器中运行它时,我收到一个导入错误:没有名为 numpy 的模块,对于 Z3A43B4F88325D94022C0EFA9C2FA2 也是如此How do I fix this?我该如何解决? Is this due to the packages being installed in a different location than where I am downloading the code?这是因为软件包安装在与我下载代码的位置不同的位置吗? Everything is installed with Anaconda, and when I try to do ```conda install numpy`` it tells me that all packages have already been installed.一切都安装了 Anaconda,当我尝试执行“conda install numpy”时,它告诉我所有的包都已经安装了。

This may be because Pycharm and Atom are using your default python install rather than your anaconda python environment.这可能是因为 Pycharm 和 Atom 正在使用您的默认 python 安装,而不是您的 anaconda Z23EEEB4347BDD26BDDZ6B7EE 环境。

You can configure Pycharm to use your conda environment via ( https://www.jetbrains.com/help/pycharm/conda-support-creating-conda-virtual-environment.html ).您可以通过( https://www.jetbrains.com/help/pycharm/conda-support-creating-conda-virtual-environment.ZFC35FDC70D5FC67A53EZ8A.8228 )配置 Pycharm 以使用您的 conda 环境

Anaconda uses virtual conda environments to store the Python interpreter and libraries. Anaconda 使用虚拟 conda 环境来存储 Python 解释器和库。 If this isn't set up in your IDE, it won't see the libraries.如果您的 IDE 中没有设置,它将看不到库。 This is described in this post: Use Conda environment in pycharm这篇文章对此进行了描述: 在 pycharm 中使用 Conda 环境

Check your PyCharm interpreter options: File > Settings > Project > Project Interpreter .检查您的 PyCharm 解释器选项: File > Settings > Project > Project Interpreter Make sure your desired Anaconda interpreter/environment is selected.确保选择了所需的 Anaconda 解释器/环境。

If your Anaconda environment isn't selected, click the Project Interpreter drop-down.如果未选择 Anaconda 环境,请单击Project Interpreter下拉菜单。 if you see it there, select it.如果你在那里看到它,select 它。 If not, click Show All... then + (Add) and browse to the Anaconda folder.如果没有,请单击Show All... ,然后单击+ (Add)并浏览到 Anaconda 文件夹。

This post describes how to set up conda in Atom: Using anaconda environment in Atom这篇文章描述了如何在 Atom 中设置 conda: Using anaconda environment in Atom

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM