导入 numpy 不能在 Python 2.7 笔记本上工作?

Import numpy not working on Python 2.7 notebook?

我在 Ubuntu 上使用 Anaconda 安装了 python,它安装了默认版本 3。但是,我正在学习使用 2.7 的 Titanic Kaggle 教程,因此给我带来了很多麻烦错误。我设法安装了 Python 2.7 以与我的 Jupyter 笔记本一起使用,但每当我尝试导入 numpy 时,它都会告诉我没有名为 numpy 的模块,即使导入功能在 Python 3 上运行得非常好笔记本。

我在这里做错了什么?如何让导入功能在 Python 2.7 笔记本上工作?

在 Ubuntu,生活很轻松,numpy 有 python2 和 python3 的包裹。

sudo apt-get install python-numpy python3-numpy -y

这应该可以修补你。 numpy 包在 Python 2 和 Python 3 内核中对我可用,运行 Jupyter 在 Python 3 下,在新的 Ubuntu Digital Ocean 上的 16.04 实例(14.04 也可以,但安装的是已过时的 Numpy 1.8。建议升级到 16.04)

在 Jupyter 中安装 Python 2 内核过去有点棘手,但现在 Jupyter 文档非常好。