简体   繁体   中英

Sometimes Unable to Import NumPy

When I work in Jupyter Notebooks everything works fine, and I can import numpy and pandas successfully. 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.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.

This may be because Pycharm and Atom are using your default python install rather than your anaconda python environment.

You can configure Pycharm to use your conda environment via ( https://www.jetbrains.com/help/pycharm/conda-support-creating-conda-virtual-environment.html ).

Anaconda uses virtual conda environments to store the Python interpreter and libraries. If this isn't set up in your IDE, it won't see the libraries. This is described in this post: Use Conda environment in pycharm

Check your PyCharm interpreter options: File > Settings > Project > Project Interpreter . Make sure your desired Anaconda interpreter/environment is selected.

If your Anaconda environment isn't selected, click the Project Interpreter drop-down. if you see it there, select it. If not, click Show All... then + (Add) and browse to the Anaconda folder.

This post describes how to set up conda in Atom: Using anaconda environment in Atom

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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