我的文件夹结构是这样设置的:
- project/
- notebooks/
- notebook1.ipynb
- src/
- module1.py
- __init__.py
- data/
- data.csv
Run Code Online (Sandbox Code Playgroud)
这样我就可以将我的源代码与实际分析分开。我希望能够从中导入模块src并在其中使用它们notebook1,但是每当我打开时notebook1,Jupyter 决定将我的工作目录更改为 inside notebooks。
这使我的导入更难维护,因为我必须相对于 Jupyter 的心血来潮导入东西 - 有什么方法可以修复cwd它project,无论我打开什么文件?
我浏览了文档和我的~/.jupyter/jupyter_notebook_config.py, 文件,但没有发现任何可以帮助我的东西。
编辑:我不想在每个脚本的顶部使用os.chdir或cd。
谢谢你的帮助
I am trying to run python code using the jupyter extension in vscode here
I have a workspace open at this location /Users/user/Documents/ When I try and run the following code in a file called test.py in a child directory, the current working directory is set at the workspace level rather than the file. Is it possible to change a setting to use the cwd of the file, rather than the workspace? I cannot find one in settings.json and the …