jupyter_server 本地如何调试
时间: 2023-08-15 21:06:00 浏览: 51
要在本地进行 jupyter_server 的调试,可以按照以下步骤:
1. 安装依赖:需要安装 jupyter_server 和 ptvsd,可以使用 pip 进行安装。
```
pip install jupyter_server
pip install ptvsd
```
2. 在代码中添加调试器:在你的代码中添加以下代码,以启用 ptvsd 调试器。
```python
import ptvsd
# Allow other computers to attach to ptvsd at this IP address and port.
ptvsd.enable_attach(address=('0.0.0.0', 5678))
```
3. 启动 jupyter_server:在终端中输入以下命令,以启动 jupyter_server。
```
jupyter server --debug
```
4. 启动调试器:在你的代码中添加断点,并在 Visual Studio Code 中启动调试器。在“Run and Debug”菜单中,选择“Python: Attach”配置,并将端口设置为 5678。
5. 连接调试器:在浏览器中打开 jupyter_notebook,访问 http://localhost:8888,并进入要调试的 notebook。在代码中执行到断点处时,调试器会停在断点处,此时你可以在 Visual Studio Code 中进行调试。
希望这些步骤能够帮助你在本地调试 jupyter_server。
相关问题
jupyter_server 本地如何使用postman调试接口api
在本地使用 Postman 调试 jupyter_server 的 API 接口,可以按照以下步骤:
1. 启动 jupyter_server:在终端中输入以下命令,以启动 jupyter_server。
```
jupyter server
```
2. 获取 jupyter_server 的 API 地址:在 jupyter_notebook 中,点击右上角的“New”按钮,在下拉菜单中选择“Terminal”,进入终端。在终端中输入以下命令,以获取 jupyter_server 的 API 地址。
```
jupyter server --generate-config
cat ~/.jupyter/jupyter_server_config.py | grep "c.ServerApp"
```
3. 在 Postman 中创建请求:打开 Postman,点击左上角的“New”按钮,选择“Request”。在请求中填写以下信息:
- 请求方式:选择“GET”或“POST”等请求方式。
- 请求地址:填写步骤2中获取到的 jupyter_server 的 API 地址。
- 请求头:填写请求头信息,例如“Content-Type: application/json”等。
- 请求体:填写请求体信息,例如“{'data': 'hello world'}”等。
4. 发送请求并查看响应:点击请求右侧的“Send”按钮,发送请求。在响应中,可以查看 jupyter_server 返回的数据,例如“{'result': 'hello world'}”等。
希望这些步骤能够帮助你在本地使用 Postman 调试 jupyter_server 的 API 接口。
jupyter_server 本地如何访问swagger
在本地访问 Jupyter Server 的 Swagger UI,需要先安装 `jupyterlab_server` 和 `jupyter_server` 扩展。可以通过以下命令来安装:
```
pip install jupyterlab_server jupyter_server
```
安装完成后,在终端运行以下命令启动 Jupyter Server:
```
jupyter server
```
启动后,可以在浏览器中访问 `http://localhost:8888/swagger` 来打开 Swagger UI。在 Swagger UI 中,可以查看 Jupyter Server 的 RESTful API,测试 API 接口,以及获取 API 文档等功能。