Greg Thatcher
Greg Thatcher

Reputation: 1443

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.

Upvotes: 6

Views: 5583

Answers (2)

ANDgineer
ANDgineer

Reputation: 680

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

Upvotes: 2

Terry Szymanski
Terry Szymanski

Reputation: 119

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.)

Upvotes: 4

Related Questions