龙空技术网

双击打开ipynb文件

每日长点知识君 193

前言:

此刻咱们对“python脚本执行ipynb文件”大约比较关切,大家都想要剖析一些“python脚本执行ipynb文件”的相关文章。那么小编在网络上收集了一些有关“python脚本执行ipynb文件””的相关内容,希望兄弟们能喜欢,姐妹们快快来了解一下吧!

因为ipynb文件是jupyter notebook的文件,每次打开总要先打开jupyter notebook,再更改路径,打开对应的ipynb文件,则很麻烦。

所以想用双击就直接打开ipynb文件。

双击自动打开文件

找到Jupyter Notebook的快捷方式,点击右键-属性-快捷方式-目标里,复制出来,如下图所示

    C:\ProgramData\Anaconda3\python.exe C:\ProgramData\Anaconda3\cwp.py C:\ProgramData\Anaconda3 C:\ProgramData\Anaconda3\python.exe C:\ProgramData\Anaconda3\Scripts\jupyter-notebook-script.py %USERPROFILE%

把该段文本复制到一个txt文本中,替换最后的 %USERPROFILE% 为 %1,注意保留空格。

    C:\ProgramData\Anaconda3\python.exe C:\ProgramData\Anaconda3\cwp.py C:\ProgramData\Anaconda3 C:\ProgramData\Anaconda3\python.exe C:\ProgramData\Anaconda3\Scripts\jupyter-notebook-script.py  %1

将该文本保存为open_ipynb.bat文件。

点击.ipynb文件右键-常规-打开方式,选择open_ipynb.bat文件。这样就可以直接双击自动打开ipynb文件了。


到这里就已经ok了。如果有报错的话,请看下面。



启动错误

按照上面修改.bat文件,双击之后,会跳出下面404:not Found错误,“You are requesting a page that does not exist!”

仔细排查原因,在Jupyter Notebook 启动在命令窗口下发现会显示错误:

     Error loading server extension jupyterlab        Traceback (most recent call last):          File "C:\ProgramData\Anaconda3\lib\site-packages\jupyterlab\commands.py", line 321, in __init__            self._run(['node', 'node-version-check.js'], cwd=HERE, quiet=True)          File "C:\ProgramData\Anaconda3\lib\site-packages\jupyterlab\commands.py", line 1165, in _run            proc = Process(cmd, **kwargs)          File "C:\ProgramData\Anaconda3\lib\site-packages\jupyterlab\process.py", line 73, in __init__            self.proc = self._create_process(cwd=cwd, env=env)          File "C:\ProgramData\Anaconda3\lib\site-packages\jupyterlab\process.py", line 131, in _create_process            cmd[0] = which(cmd[0], kwargs.get('env'))          File "C:\ProgramData\Anaconda3\lib\site-packages\jupyterlab\jlpmapp.py", line 59, in which            raise ValueError(msg)        ValueError: Please install nodejs 5+ and npm before continuing installation. nodejs may be installed using conda or directly from the nodejs website.
        During handling of the above exception, another exception occurred:
        Traceback (most recent call last):          File "C:\ProgramData\Anaconda3\lib\site-packages\notebook\notebookapp.py", line 1454, in init_server_extensions            func(self)          File "C:\ProgramData\Anaconda3\lib\site-packages\jupyterlab\extension.py", line 111, in load_jupyter_server_extension            info = get_app_info(app_dir)          File "C:\ProgramData\Anaconda3\lib\site-packages\jupyterlab\commands.py", line 244, in get_app_info            handler = _AppHandler(app_dir, logger)          File "C:\ProgramData\Anaconda3\lib\site-packages\jupyterlab\commands.py", line 324, in __init__            raise ValueError(msg)        ValueError: Please install nodejs 5+ and npm before continuing installation. nodejs may be installed using conda or directly from the nodejs website.

原因:因为我使用的Anaconda3中jupyterlab 0.31.4版本存在错误,更新即可消除该错误。

解决方法:打开anaconda navigator,点击右上角,update Application

或者直接在命令行里输入直接升级jupyterlab

    pip install --upgrade jupyterlab

标签: #python脚本执行ipynb文件 #cmd命令打不开jupyterlab