[英]How to make jupyter start in current directory by default (in cmd.exe)?
In Windows 10 cmd.exe
I can start jupyter
in a current directory by following command: 在Windows 10
cmd.exe
我可以通过以下命令在当前目录中启动jupyter
:
jupyter notebook --notebook-dir="."
The current directory is C:\\Users\\Евгений\\Documents\\GitHub\\sandbox
当前目录为
C:\\Users\\Евгений\\Documents\\GitHub\\sandbox
However, when I start simply jupyter notebook
in a current directory above my working directory for jupyter is D:/git
: 但是,当我在
jupyter notebook
工作目录上方的当前目录中简单地启动jupyter notebook
,则为D:/git
:
λ cd
C:\Users\Евгений\Documents\GitHub\sandbox
λ jupyter notebook
[I 14:46:44.273 NotebookApp] The port 8888 is already in use, trying another port.
[I 14:46:44.304 NotebookApp] JupyterLab beta preview extension loaded from D:\Anaconda3\lib\site-packages\jupyterlab
[I 14:46:44.304 NotebookApp] JupyterLab application directory is D:\Anaconda3\share\jupyter\lab
[I 14:46:44.571 NotebookApp] Serving notebooks from local directory: D:/git
Note the last line Serving notebooks from local directory: D:/git
. 请注意
Serving notebooks from local directory: D:/git
的最后一行Serving notebooks from local directory: D:/git
。 Where is D:/git
may be coming from? D:/git
可能来自哪里? Are there environment variables other than these affecting working directory choice? 除了这些以外,还有其他环境变量会影响工作目录的选择吗?
%USERPROFILE%/.jupyter
is totally empty. %USERPROFILE%/.jupyter
完全为空。 jupyter --config-dir
directs to C:\\Users\\Евгений\\.jupyter
, it is %USERPROFILE%/.jupyter
. jupyter --config-dir
指向C:\\Users\\Евгений\\.jupyter
,它是%USERPROFILE%/.jupyter
。 I read various threads about jupyter invoke, in particular: 我阅读了有关jupyter invoke的各种主题,特别是:
jupyter notebook
will behave differently in cmd.exe
and Anaconda prompt, without further details though jupyter notebook
在cmd.exe
和Anaconda提示符下的行为将有所不同,尽管没有进一步的细节 --notebook-dir="."
--notebook-dir="."
key into a .bat file My other thought is that %USERPROFILE%
with non-Latin character is not be recongnisable by jupyter
, but %USERPROFILE%/.jupyter
is empty anyways. 我的另一个想法是,
%USERPROFILE%
非拉丁字符不能被recongnisable jupyter
,但%USERPROFILE%/.jupyter
是空的反正。
You must generate the configuration of Jupyter . 您必须生成Jupyter的配置 。
jupyter notebook --generate-config
Navigate to your folder and the folder .jupyter (C:\\Users\\%username%\\.jupyter) 导航到您的文件夹和文件夹.jupyter (C:\\ Users \\%username%\\。jupyter)
You will find a file called jupyter_notebook_config.py 您将找到一个名为jupyter_notebook_config.py的文件。
Edit it with notepad++ for exemple and locate c.NotebookApp.notebook_dir 例如,使用notepad ++对其进行编辑,然后找到c.NotebookApp.notebook_dir
Between ' ' put the path you want. 在“”之间放置所需的路径。 For exemple :
举个例子 :
c.NotebookApp.notebook_dir = 'C:/Users/Евгений/Documents/GitHub/sandbox'
Save it and start Jupyter without specifying a path 保存它并在不指定路径的情况下启动Jupyter
Be careful, the characters in your username may be a problem. 请注意,用户名中的字符可能是一个问题。
Keep me informed. 让我知情。
Use the jupyter notebook config file: 使用jupyter笔记本配置文件:
Open cmd
(or Anaconda Prompt) and run jupyter notebook --generate-config
. 打开
cmd
(或Anaconda Prompt)并运行jupyter notebook --generate-config
。
This writes a file to C:\\Users\\username\\.jupyter\\jupyter_notebook_config.py
. 这会将文件写入
C:\\Users\\username\\.jupyter\\jupyter_notebook_config.py
。
Browse to the file location and open it in an Editor 浏览到文件位置并在编辑器中将其打开
Search for the following line in the file: #c.NotebookApp.notebook_dir = ''
在文件中搜索以下行:
#c.NotebookApp.notebook_dir = ''
Replace by c.NotebookApp.notebook_dir = 'D:/git'
替换为
c.NotebookApp.notebook_dir = 'D:/git'
Make sure you use forward slashes in your path 确保在路径中使用正斜杠
Remove the # at the beginning of the line to allow the line to execute 删除该行开头的#,以允许该行执行
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.