简体   繁体   中英

How to Change Port used by Anaconda/Jupyter Notebooks in Visual Studio Code

I am using Visual Studio Code version 1.36.1 (the latest) to run and debug Python code. When I do this, Visual Studio Code creates a Python process which binds to port 8888. I believe this is the Anaconda environment used by Jupyter notebooks. Unfortunately, other applications, such as Fiddler also use port 8888 by default.

Is there a way to change this default port of 8888 to something else?

I'm guessing that there's something I could put in AppData\\Roaming\\Code\\User\\settings.json, and suspect the answer will look like this one , but I need to know what that setting is.

VS Code now has an option to specify custom command line arguments for the Jupyter process. To change the default port, go to the Command Palette and choose the Python: Specify Jupyter command line arguments command. Then choose Custom and enter the command line arguments you want. For me, it was something like this:

--NotebookApp.port=9999 --notebook-dir=/tmp

(I had to add the notebook dir folder option as well, because when you use this option you lose all of the other parameters that VS Code sets, and Jupyter was trying to write to the root folder, which was giving other errors.)

Alternatively you can add command line parameters in config file

{
  "terminal.integrated.inheritEnv": false,
  "python.dataScience.jupyterCommandLineArguments": [
    "--port=8890", "--ip=127.0.0.1"    
  ]
}

In the file ~/Library/Application support/Code/User/settings.json

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM