Python软件包是在终端上导入的,而不是在IDLE上导入的 [英] Python packages are imported on terminal but not on IDLE

查看:203
本文介绍了Python软件包是在终端上导入的,而不是在IDLE上导入的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我是Python的新手.我下载了Anaconda(和Homebrew),并在Mac上使用Terminal时,我确认已安装了Numpy:

So I am new in Python. I downloaded Anaconda (and Homebrew) and using Terminal on my Mac I confirmed that, say, Numpy is installed:

pip install numpy

获得结果

Requirement already satisfied: numpy in ./anaconda/lib/python3.6/site-packages

然后在Terminal I中打开Python确实可以导入该包.打开IDLE后,故事就不同了.因此,当我打开它并尝试导入时,例如Numpy,我收到以下消息:

Then opening Python within Terminal I can indeed import the package. The story is not the same once I open IDLE. So when I open it and try to import, say, Numpy I get the following message:

    Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    import numpy
ModuleNotFoundError: No module named 'numpy'

我猜有一些我不知道的东西,我认为这是一个常见的菜鸟问题.你能帮我吗?

I guess there is something I do not know, I assume it is a common rookie problem. Can you help me with this?

推荐答案

请参见使用Anaconda时,它会创建自己的虚拟环境. 现在,如果您是MAC上的python的新手,那么您可能不熟悉Virtual Environment.

See when you are working with Anaconda it creates its own virtual environment. Now, If you are new in python on MAC then you might not familiar with Virtual Environment.

我建议您从官方网站 www.python.org python > 或点击此处以直接在您的MAC上下载Python 3.6.2.

I suggest you to download python from the official website www.python.org or Click here to directly download Python 3.6.2 on your MAC.

然后,下载 Pycharm (适用于Python的最佳IDE) 下载面向初学者的社区版本,它也是免费的.

Then, Download Pycharm(The Best IDE for Python) Download the community version for beginner and it is also free.

Pycharm社区版本-> 单击此处

Pycharm Community Version -> Click Here

做任何您想做的事,还必须阅读有关 Virtualenv

And do whatever you want and also must read about Virtualenv

根据我的说法, Pycharm比Anaconda的Jupyter Notebook更好

祝您好运,并在python中展示您的创造力! !

Wish you good luck and show your creativity in python ! !

这篇关于Python软件包是在终端上导入的,而不是在IDLE上导入的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆