导入错误:没有名为 IPython 的模块

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/45179915/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 16:47:40  来源:igfitidea点击:

ImportError: No module named IPython

pythonpython-2.7ipython

提问by Jhonatan

When i try to use from IPython.display import clear_output, display_html, then i show the error:

当我尝试使用from IPython.display import clear_output, display_html 时,我显示错误:

Error Image
(ImportError: No module named IPython)

错误图像
(导入错误:没有名为 IPython 的模块)

I am using Python 2.7.13, and im trying to make the game of life from John Conway. I am following this link: http://nbviewer.jupyter.org/url/norvig.com/ipython/Life.ipynb

我正在使用 Python 2.7.13,我正在尝试制作 John Conway 的生活游戏。我正在关注此链接:http: //nbviewer.jupyter.org/url/norvig.com/ipython/Life.ipynb

I have read another questions and answers about it, but any answer works for me. First, this error is showed in command line, and when i try to run this code in a file. Second, this error is direct to IPython, not submodule or something similiar.

我已经阅读了关于它的另一个问题和答案,但任何答案都对我有用。首先,此错误显示在命令行中,当我尝试在文件中运行此代码时。其次,这个错误直接针对 IPython,而不是子模块或类似的东西。

采纳答案by Jhonatan

Ok, finally i achieved my goal.

好的,我终于达到了我的目的。

  1. I wrote ipython --versionbut i found, it was not installed.
  2. I tried to install it, with pip. I went to C:\Python27\Scripts, here is pip, you can try in this directory, or add to environment variables.
  3. I tried to install ipython, but i found a error
  1. 我写了ipython --version但我发现它没有安装。
  2. 我尝试使用 pip 安装它。我去了C:\Python27\Scripts,这里是pip,你可以在这个目录下试试,或者添加到环境变量中。
  3. 我尝试安装 ipython,但发现错误

error: Unable to find vcvarsall.bat

错误:无法找到 vcvarsall.bat

so i installed visual studio c++ 9.0, the version to python 2.7.

所以我安装了visual studio c++ 9.0,python 2.7的版本。

  1. pip install ipython
  1. pip 安装 ipython

回答by Shital Shah

For Anaconda try,

对于 Anaconda 尝试,

conda install -c anaconda ipython

回答by Anamitra Musib

Use this code to install the IPython library:

使用此代码安装 IPython 库:

!pip install ipython
import IPython

Well, this works on Google Colab.

嗯,这适用于 Google Colab。

回答by Tessaracter

This is most likely because ipythonis not installed.

这很可能是因为ipython未安装。

You can install it with pip.

您可以使用pip.

pip install ipython

If you are using Anaconda (the full version) ipythoncomes preinstalled. If you are using Miniconda or if the ipython is deleted for some reason you can re-install with

如果您使用的ipython是预装的Anaconda(完整版)。如果您正在使用 Miniconda 或者如果 ipython 由于某种原因被删除,您可以重新安装

conda install -c anaconda ipython

If you are using it with jupyter. You might want to register the ipythonwith a user.

如果您将它与jupyter. 您可能希望向ipython用户注册。

python -m ipykernel install [--user] [--name <machine-readable-name>] [--display-name <"User Friendly Name">]

Reference :

参考 :

  1. Official Documentation
  1. 官方文档