简体   繁体   中英

How do I open a .py file in the notebook editor of VSCode

VSCode has a notebook editor that works for .ipynb files. Is it possible to open a regular .py file (optionally annotated with the "percent" syntax) in the integrated notebook editor? If yes, how?

Right clicking the file in the editor or the file explorer gives no option of opening with the notebook editor. Also running the "Open in Notebook Editor" and "Open in Preview Notebook Editor" commands from the Command Palette doesn't seem to do anything.

Only reference I could find is the following, however that refers to .ipynb only: https://code.visualstudio.com/docs/python/jupyter-support#_create-or-open-a-jupyter-notebook

I'm a developer on this extension. The notebook editor is just for opening up Notebook (.ipynb) files. .py files will open up in the normal VSCode editor. However if you have code cell (#%%) annotations in your.py file you should have both CodeLenses and command palette commands that you can use to run blocks of code in jupyter. The output from those blocks will show up in an interactive window that is similar to the notebook editor.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM