如何让 Jupyter notebook 在系统变量中使用 PYTHONPATH 而不直接破解 sys.path? [英] How to make Jupyter notebook use PYTHONPATH in system variables without hacking sys.path directly?

查看:34
本文介绍了如何让 Jupyter notebook 在系统变量中使用 PYTHONPATH 而不直接破解 sys.path?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与此问题相同的问题Jupyter 和 Python 中的 sys.path 不同 - 如何在 Jupyter 中导入自己的模块?.在纯 Python 中,它将我的系统环境变量 PYTHONPATH 添加到 sys.path 但 Jupyter notebook 没有,所以我无法导入我自己的模块.

Same problem as in this question sys.path different in Jupyter and Python - how to import own modules in Jupyter?. In pure Python, it prepends my system environment variable PYTHONPATH to sys.path but Jupyter notebook doesn't, so I can't import my own module.

SO上问了很多类似的问题,解决办法是直接在脚本中操作sys.path.

There are many similar questions asked on SO, and the solution is to directly manipulate sys.path in the script.

有没有办法让 Jupyter notebook 使用我的系统 PYTHONPATH 变量,就像在纯 python 中一样?

Is there a way to make Jupyter notebook use my system PYTHONPATH variable, as in pure python?

推荐答案

Jupyter 使用自己的 JUPYTER_PATH 环境变量.

Jupyter uses its own JUPYTER_PATH environment variable.

这篇关于如何让 Jupyter notebook 在系统变量中使用 PYTHONPATH 而不直接破解 sys.path?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆