相关疑难解决方法(0)

防止 Jupyter Notebooks 更改 cwd

我的文件夹结构是这样设置的:

- 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 的心血来潮导入东西 - 有什么方法可以修复cwdproject,无论我打开什么文件?

我浏览了文档和我的~/.jupyter/jupyter_notebook_config.py, 文件,但没有发现任何可以帮助我的东西。

编辑:我不想在每个脚本的顶部使用os.chdircd

谢谢你的帮助

python jupyter-notebook jupyter-console

5
推荐指数
1
解决办法
363
查看次数

Wrong current working directory when running python code and jupyter extension in vscode

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 …

python jupyter visual-studio-code

5
推荐指数
1
解决办法
4826
查看次数