简体   繁体   English

无法使用“从 numpy 导入 *”

[英]Unable to use “from numpy import *”

I was trying to import numpy like the below format, but it was not working.我试图像下面的格式一样导入numpy ,但它不起作用。 It was throwing me some errors.它给了我一些错误。 The IDE was VS Code. IDE 是 VS 代码。 I already installed NUMPY in pip on CMD.我已经在 CMD 上的 pip 中安装了 NUMPY。 Still it is not working.仍然无法正常工作。 This is the Screenshot of Error in VS code这是 VS 代码中的错误截图

These are more warnings than errors in your screenshot这些警告多于屏幕截图中的错误

You're importing everything from the numpy namespace.您正在从 numpy 命名空间导入所有内容。 These errors indicate that you aren't using any of these classes yet.这些错误表明您还没有使用这些类中的任何一个。 Pylint is telling you on each warning line of the Problems Tab, there is an "unused-wildcard-import" (That import is not being used in your code yet) Pylint 在“问题”选项卡的每个警告行都告诉您,有一个“未使用的通配符导入” (该导入尚未在您的代码中使用)

If you only need to import certain classes from numpy I would reccomend importing only what's neccessary如果您只需要从 numpy 导入某些类,我建议只导入必要的

For example:例如:

from numpy import [required_import], [required_import2], ...etc.
#These packages can be separated out in commas as shown above

Try comment or omit this import statement out and only use imports where neccessary from numpy尝试注释或省略此导入语句,仅在必要时使用来自 numpy 的导入

Also good to verify you have numpy installed by也很高兴验证您安装了 numpy

try:
    import numpy
except ImportError:
    print("Numpy not Installed")

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

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