在 Windows 10 (Anaconda) 中将 ipynb 文件与 Jupyter Notebook 关联
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47267932/
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
Associate ipynb files with Jupyter notebook in Windows 10 (Anaconda)
提问by DeltaIV
I installed Anaconda 5.0.1 on my Windows 10 machine. I have a few Jupyter notebooks on my pc and I would like to associate them with Jupyter, to avoid having to open Jupyter and navigate to the notebooks folders each time. Is that possible?
我在 Windows 10 机器上安装了 Anaconda 5.0.1。我的电脑上有几个 Jupyter 笔记本,我想将它们与 Jupyter 相关联,以避免每次都必须打开 Jupyter 并导航到笔记本文件夹。那可能吗?
PS I asked here because I figured this question to be more of interest for programmers, but if you think it would be more suited for SuperUser, I'll flag it for migration.
PS 我在这里问是因为我认为这个问题对程序员更感兴趣,但是如果您认为它更适合超级用户,我会将其标记为迁移。
回答by endolith
Install nbopen
: https://github.com/takluyver/nbopen
安装nbopen
:https: //github.com/takluyver/nbopen
pip install nbopen
python -m nbopen.install_win
Now you can double-click on *.ipynb
files:
现在您可以双击*.ipynb
文件:
回答by fredm73
associate .ipnyb with jupyter-notebook.exe
将 .ipnyb 与 jupyter-notebook.exe 关联
On Windows 10: control panel/Programs/Default Programs/Associate a file type or protocol with a program/Choose default apps by file type
在 Windows 10 上:控制面板/程序/默认程序/将文件类型或协议与程序关联/按文件类型选择默认应用程序
Look at the list of extensions, find '.ipnyb'. Click on icon and locate the jupyter notebook program. In my Anaconda installation, it is found at anaconda/scripts/jupyter-notebook.exe
查看扩展名列表,找到“.ipnyb”。单击图标并找到 jupyter notebook 程序。在我的 Anaconda 安装中,它位于 anaconda/scripts/jupyter-notebook.exe
回答by schendi
If you have Jupyter installed with Anaconda you can do the following.
如果您安装了带有 Anaconda 的 Jupyter,您可以执行以下操作。
Create a little batch file (e.g. start_jupyter_notebook.bat) with the content (the commands are from the Jupyter shortcut):
创建一个包含内容的小批处理文件(例如 start_jupyter_notebook.bat)(命令来自 Jupyter 快捷方式):
@echo off
set ANACONDAPATH=C:\_work\_programs\Anaconda3
%ANACONDAPATH%\python.exe %ANACONDAPATH%\cwp.py %ANACONDAPATH%^
%ANACONDAPATH%\python.exe %ANACONDAPATH%\Scripts\jupyter-notebook-script.py %1
(of course you will have to change the ANACONDAPATH to your installation)
(当然,您必须将 ANACONDAPATH 更改为您的安装)
Then go to one .ipynb file of your choice, right-click on it, go to properties --> open with --> change and select your created batch file.
然后转到您选择的一个 .ipynb 文件,右键单击它,转到属性 --> 打开方式 --> 更改并选择您创建的批处理文件。
I am pretty sure this can also be setup for any other Python/Jupyter installation.
我很确定这也可以为任何其他 Python/Jupyter 安装设置。
P.S. The cwp.py file sets up some environment variables. I guess this is the reason why fredm73's answer did not work for everybody. Apart from that my answer is quite similar in the end.
PS cwp.py 文件设置了一些环境变量。我想这就是 fredm73 的答案对每个人都不起作用的原因。除此之外,我的答案最终非常相似。
回答by Amir F
Easiest way for me - double click on the .ipnyb file. When prompted to pick a program to open the extension with go to /ProgramData/Anaconda3/Scripts and locate the jupyter-notebook.exe file and click it.
对我来说最简单的方法 - 双击 .ipnyb 文件。当提示选择一个程序来打开扩展时,转到 /ProgramData/Anaconda3/Scripts 并找到 jupyter-notebook.exe 文件并单击它。
NOTE - to access the ProgramData folder you will need to view hidden folders in the Windows explorer or access it by typing %programdata% in the navigation line:
注意 - 要访问 ProgramData 文件夹,您需要在 Windows 资源管理器中查看隐藏文件夹或通过在导航栏中键入 %programdata% 来访问它:
回答by Dhawal
Find the jupter-notebook.exe in the C:\Users\my_username\Anaconda3\Scripts folder. Copy the address. When you're opening the .ipnyb file double click ( if first time) or just do open with and there in the menu you can tick the 'always use this' option and locate the notebook from 'look more programs' option in the menu.
在 C:\Users\my_username\Anaconda3\Scripts 文件夹中找到 jupter-notebook.exe。复制地址。当您打开 .ipnyb 文件时,双击(如果是第一次)或直接在菜单中打开,您可以勾选“始终使用此”选项并从菜单中的“查看更多程序”选项中找到笔记本.
回答by wdhwg001
For those who installed nbopen in Anaconda but it does not work:
对于那些在 Anaconda 中安装了 nbopen 但它不起作用的人:
Use Regedit to search for a directory called Jupyter.nbopen
, and navigate to its shell\open\command
. It should be something like:
使用 Regedit 搜索名为 的目录Jupyter.nbopen
,并导航到其shell\open\command
. 它应该是这样的:
HKEY_USERS\****\Software\Classes\Jupyter.nbopen\shell\open\command
Then, change the default to: (Modify the path if you are not installed in default location)
然后,将默认更改为:(如果没有安装在默认位置,请修改路径)
"C:\ProgramData\Anaconda3\pythonw.exe" "C:\ProgramData\Anaconda3\cwp.py" "C:\ProgramData\Anaconda3" "C:\ProgramData\Anaconda3\pythonw.exe" -m nbopen "%1"
The reason behind this is that cwp.py
makes sure that the Jupyter is running in Anaconda instead of other Python environments.
这背后的原因是cwp.py
确保 Jupyter 在 Anaconda 而不是其他 Python 环境中运行。
Then it should work, although it will activate two invisible pythonw process running in the background.
然后它应该可以工作,尽管它会激活在后台运行的两个不可见的pythonw进程。