python - 无法从pycharm导入numpy

标签 python python-3.x numpy anaconda

我有 Anaconda3。当我从 Pycharm 或直接从文件夹使用它的解释器导入 numpy 时,出现以下错误:

ImportError                               Traceback (most recent call last)
~\Anaconda\lib\site-packages\numpy\core\__init__.py in <module>
     16 try:
---> 17     from . import multiarray
     18 except ImportError as exc:

~\Anaconda\lib\site-packages\numpy\core\multiarray.py in <module>
     13
---> 14 from . import overrides
     15 from . import _multiarray_umath

~\Anaconda\lib\site-packages\numpy\core\overrides.py in <module>
      6
----> 7 from numpy.core._multiarray_umath import (
      8     add_docstring, implement_array_function, _get_implementing_args)

ImportError: DLL load failed: The specified module could not be found.

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-1-d4cdadb62aa7> in <module>
----> 1 import numpy

~\Anaconda\lib\site-packages\numpy\__init__.py in <module>
    140     from . import _distributor_init
    141
--> 142     from . import core
    143     from .core import *
    144     from . import compat

~\Anaconda\lib\site-packages\numpy\core\__init__.py in <module>
     45 """ % (sys.version_info[0], sys.version_info[1], sys.executable,
     46         __version__, exc)
---> 47     raise ImportError(msg)
     48 finally:
     49     for envkey in env_added:

ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy c-extensions failed.
- Try uninstalling and reinstalling numpy.
- If you have already done that, then:
  1. Check that you expected to use Python3.7 from "C:\Users\noamw\Anaconda\python.exe",
     and that you have no directories in your PATH or PYTHONPATH that can
     interfere with the Python and numpy version "1.17.4" you're trying to use.
  2. If (1) looks fine, you can open a new issue at
     https://github.com/numpy/numpy/issues.  Please include details on:
     - how you installed Python
     - how you installed numpy
     - your operating system
     - whether or not you have multiple versions of Python installed
     - if you built from source, your compiler versions and ideally a build log

- If you're working with a numpy git repository, try `git clean -xdf`
  (removes all files not under version control) and rebuild numpy.

Note: this error has many possible causes, so please don't comment on
an existing issue about this - open a new one instead.

Original error was: DLL load failed: The specified module could not be found.

但是,当我在激活我的环境后使用 conda 从 ipython 使用它时,它工作得很好。不能像这样创建 Pycharm 项目真的很令人沮丧。 非常感谢任何帮助 谢谢

最佳答案

将您的环境设置为 PyCharm 的解释器应该可行。转到 Preferences --> Project --> Project Interpreter。在下拉菜单中选择您的 conda 环境。将其设置为类似:~/Anaconda3/envs/myenvname/bin/python

关于python - 无法从pycharm导入numpy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59644538/

相关文章:

python - PyLint/PyLint3 无法识别文档字符串

python - 如何在Python中根据条件对多列进行分组并创建新列?

python - 生成器函数在列表和生成器表达式上的行为不同?

python - 如何按列的绝对值对numpy数组进行排序?

python - 在 Pandas 中以均值转换组的更快方法

python - 从图像中获取RGB数据并将其与相应像素写入CSV文件

javascript - 将 Django 模板转换为 pdf

python - 如何从值列表创建 Django 查询集

python - keras 中的自定义 keras.applications 模型

python-3.x - Python colorama 不处理输入?