"Forbidden" error occurred in jupyter notebook

When running and starting jupyter notebook in the terminal, a "Forbidden" error appears when creating a new file.

[W 08:32:54.925 NotebookApp] wrote error: 'Forbidden'
    Traceback (most recent call last):
      File "/Users/linql/anaconda3/envs/tensorflow/lib/python3.11/site-packages/tornado/web.py", line 1711, in _execute
        result = method(*self.path_args, **self.path_kwargs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/Users/linql/anaconda3/envs/tensorflow/lib/python3.11/site-packages/tornado/web.py", line 3196, in wrapper
        url = self.get_login_url()
              ^^^^^^^^^^^^^^^^^^^^
      File "/Users/linql/anaconda3/envs/tensorflow/lib/python3.11/site-packages/jupyter_server/base/handlers.py", line 747, in get_login_url
        raise web.HTTPError(403)
    tornado.web.HTTPError: HTTP 403: Forbidden

Check the cause. It may be a port conflict. Try changing the port number during debugging.

【1】Open terminal or command prompt: Open a new terminal window or command prompt window.

【2】Enter the Jupyter Notebook configuration directory: Enter the following command in the terminal to enter the Jupyter Notebook configuration directory:

jupyter notebook --generate-config

 [3] Open the configuration file: According to the file path, you can open it directly with Vim, or you can access the file path in Finder through the shortcut key "command+shift+G". After finding the file, open it with sublime Text.

【4】Search and modify port settings: Search for this line in the configuration file c.NotebookApp.port. Set it to the new port number you want to use. For example, to change the port number to 9999, you would change the line to:

 【5】Save and close the configuration file: Save the modified configuration file in the text editor and close the editor.

【6】Start Jupyter Notebook.

Guess you like

Origin blog.csdn.net/qq_23938507/article/details/131370115