How to Use a Jupyter Notebook in Visual Studio 2017?

混江龙づ霸主 提交于 2019-12-21 07:51:11

问题


Visual Studio 2017 now supports use of a Jupyter Notebook.

A Lap Around Python in Visual Studio 2017

According to the MSDN blog post:

To work with a notebook, simply download your IPYNB file as a .py file and open it in Visual Studio. You’ll see that markdown cells have been turned into comments and each cell is collapsible and expandable.

When I download a IPYNB file, rename to a .py file, it displays in the VS editor as a JSON file containing markdown. I was expecting to see a markdown file. What am I missing?


回答1:


This is what I believe they mean with download as. You need the Notebook running then click on File-> Download as-> Pythong(.py )

http://imgur.com/qbWpIlE

Once you have downloaded your Python file from the notebook you can open it in visual studio

Edited: added the rest of the answer




回答2:


@Jonathan answer is correct. The MSDN blog was referring to Jupyter Notebooks menu item File->Download->Python (.py). There's additional considerations in getting a notebook to run and ultimately a issue with quality of experience.

  1. To use a notebook in Visual Studio, download using Jupyter as stated above.
  2. Specify the Python environment as Anaconda as shown in the blog image. To do so, either set Anaconda as the default environment or create a solution from existing files that specifies Anaconda as the environment.
  3. Open a Python interactive window to display notebook execution.
  4. Use Ctrl-Enter to step through notebook's statements.

That said, be aware that Visual Studio's notebook-ish experience is not at the level of Jupyter's, for now. Until VS directly integrates notebooks (.IPYNB files), I see little advantage of using VS over the real Jupyter.

  1. VS has fewer and semantically different key bindings than Jupyter.
  2. Jupyter's formatting (HTML) is far superior to VS (text).
  3. There's little support and documentation for notebook-ish in VS.
  4. The whole VS notebook-ish experience lacks polish.
  5. IMHO, the beauty of Jupyter is the single window experience but VS uses two.



回答3:


As an alternative to Visual Studio that does not integrate well iPython notebooks, did you look at PyCharms that is a nice Python IDE (as far as I use it for now^^).

It provides a nice rendrering of ipython notebook inside the IDE making it a common IDE for python and iPython stuff. Maybe it worth a try.



来源:https://stackoverflow.com/questions/44057052/how-to-use-a-jupyter-notebook-in-visual-studio-2017

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