简体   繁体   English

在 Sublime 中找不到 Python 模块 IDE

[英]Python modules not found in Sublime IDE

I am using Sublime IDE for development.我正在使用 Sublime IDE 进行开发。 When I'm building my code on Sublime on Ubuntu 18.04, it gives me an error saying:当我在 Ubuntu 18.04 上的 Sublime 上构建代码时,它给了我一个错误消息:

ImportError: No module named numpy ImportError:没有名为 numpy 的模块

I have installed numpy on my system and it works just fine when I run it on the terminal.我已经在我的系统上安装了 numpy,当我在终端上运行它时它工作得很好。

How do I get the code to build successfully on Sublime itself?如何让代码在 Sublime 本身上成功构建? Thanks in advance.提前致谢。

It usually happens when you have installed numpy in a different version of Python.当您在不同版本的 Python 中安装 numpy 时,通常会发生这种情况。 Like you are using Python3 but numpy is installed in Python2.就像您使用 Python3 一样,但 numpy 安装在 Python2 中。 So Try to reinstall numpy by specifying the Python version.所以尝试通过指定 Python 版本来重新安装 numpy。 Try:尝试:

python3 -m pip install numpy

this will install numpy using Python3 and you will be able to use it in your IDE.这将使用 Python3 安装 numpy,您将能够在 IDE 中使用它。

As @Oleg said, the interpreter on my terminal and on Sublime were different.正如@Oleg 所说,我的终端和 Sublime 上的解释器是不同的。

https://askubuntu.com/questions/1103987/how-to-change-python-version-in-sublime-ubuntu-18 https://askubuntu.com/questions/1103987/how-to-change-python-version-in-sublime-ubuntu-18

Used the above link to change the default interpreter for Sublime.使用上面的链接更改 Sublime 的默认解释器。

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

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