Ipython is working in command prompt but not in browser

蹲街弑〆低调 提交于 2019-12-01 03:54:45

The traceback is clear:

You must install pyzmq

pyzmq is a requirement for the ipython notebook.
For a list of dependencies check this

Short answer:

make sure pyzmq is installed in the same virtualenvironment (or lack of) as ipython. For me, ipython notebook was installed as regular, but its dependencies got put in my virtualenvironment. A quick install in the proper place fixed this error for me.

Long answer:

I'm putting this solution here because the error message is the same though the scenario is different from the original poster's, I think.

I am running iPython notebook in a virtual environment on a virtual box. I think the virtual box bit is irrelevant, but the virtualenvironment is not. I installed ipython[notebook] via pip in the virtualenvironment and got the same error ImportError: IPython.html requires pyzmq >= 2.1.11

But, I could plainly see that pyzmq was installed. Both pip freeze and pip install --upgrade pyzmq showed that I had the latest pyzmq version available and it was definitely >= 2.1.11 (pip freeze|grep pyzmq gives pyzmq==14.3.1).

I exited the virtualenvironment and checked pyzmq again and discovered that pyzmq was installed only in the virtualenv. That should be the way it's supposed to work, but for some reason ipython was looking in the main python location, not the virtualenv's python location. I suspect that ipython was installed outside the virtualenvironment. I don't know why pyzmq was installed only inside it. Anyhow, pip install pyzmq while outside my virtualenvironment fixed everything and now it all works. Sorry for the verbose answer.

The iPython install documentation says:

[...] you can get IPython with pip:

pip install ipython

Or if you want to also get the dependencies for the IPython notebook:

pip install "ipython[notebook]"
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!