72

I am trying to use the Jupyter notebook in Pycharm, but I realized that in the new Jupyter update, there was the addition of tokens.

I am following the tutorial below from JetBrains.

With all the settings initiated with the virtual environment created and setting the URL as 127.0.0.1:8888, however, when I click on the run cell button, it follows that I get the following message from Jupyter Notebook asking:

Please, enter your Jupyter Notebook URL and authentication token

like this:

PyCharm error message: Enter Jupyter Notebook URL authentication token

I looked it up on the Jupyter update blog and it says that my web browser should be initiated which generates a token for access, but I do not see that my browser is loaded here.

Help would be greatly appreciated here.

Eric Leung
  • 2,354
  • 12
  • 25
PutsandCalls
  • 997
  • 1
  • 8
  • 11
  • 4
    Since at least PyCharm version 2019.1 (and perhaps the latest versions released in 2018), **support for Jupyter notebooks has been removed from the Community edition of PyCharm**. Jupyter notebooks are now only supported in the Professional edition. – Jean-François Corbett Apr 10 '19 at 13:09

6 Answers6

69

Running jupyter notebook list will display all of the running servers on your machine. So doing this in the terminal after starting a cell in PyCharm will result in output similar to Currently running servers: http://127.0.0.1:8888/?token=f85145dda03dc598bbbfa6e53b93cbcb27629ea00cfd2105 :: /home/.... which contains the appropriate token for authenticating.

patemotter
  • 1,043
  • 1
  • 11
  • 19
  • Token in this example is `f85145dda03dc598bbbfa6e53b93cbcb27629ea00cfd2105` (i.e. the string that follows `http://127.0.0.1:8888/?token=`) – Manavalan Gajapathy Jul 03 '17 at 00:27
  • 2
    Running a cell didn't start a jupyter notebook server for me. `jupyter notebook list` returned nothing. [This other answer](https://stackoverflow.com/a/45716341/119775) did work for me, so it's worth trying as well if this one doesn't work for you, the reader. – Jean-François Corbett Oct 13 '17 at 12:27
  • 2
    If it doesn't work, PyCharm gets stuck in a loop and must be kill -9'd. Cancel doesn't work. – Reb.Cabin Sep 24 '18 at 12:36
  • I only get this : jupyter notebook list: Currently running servers: http://localhost:8888/ :: C:\Users\Hemmat – Mohammad Heydari Jun 08 '19 at 20:25
  • This answer did not work for me, hence I used [this one](https://stackoverflow.com/a/54693525/3484477) which works perfectly. – Meysam Sadeghi Oct 17 '19 at 06:42
54
  1. Edit/enter the URL as: http://localhost:8888 (remove "?token=" at the end) and click OK.
  2. A bubble prompt will appear near the top of your PyCharm window, saying "Cannot connect to Jupyter Notebook. Run Jupyter Notebook". It should look like this (depending on your color scheme):

PyCharm prompt: Cannot connect to Jypyter Notebook. Run Jupyter Notebook

  1. Click on the link: "Run Jupyter Notebook"
  2. PyCharm will start the Jupyter server for you and it will create a new token. Look at View -> Tool Windows -> Run, to see details of the new token, and an optional URL to open in a web browser.

More info: https://www.jetbrains.com/help/pycharm/using-ipython-jupyter-notebook-with-pycharm.html

Jean-François Corbett
  • 37,420
  • 30
  • 139
  • 188
Mr-IDE
  • 7,051
  • 1
  • 53
  • 59
  • 3
    not working in the latest update of pycharm as for today – Khalil Al Hooti Dec 09 '18 at 00:45
  • 1
    I clicked on the "Run Jupyter Notebook" link and see this returned: [TerminalIPythonApp] WARNING | Subcommand `ipython notebook` is deprecated and will be removed in future versions. [TerminalIPythonApp] WARNING | You likely want to use `jupyter notebook` in the future [W 08:17:43.929 NotebookApp] Permission to listen on port 8888 denied [C 08:17:43.929 NotebookApp] ERROR: the notebook server could not be started because no available port could be found. – JasonArg123 Dec 11 '18 at 16:18
  • @JasonArg123 Does it work if you try the following instructions, to add the extra path to your Run Configuration? ... https://intellij-support.jetbrains.com/hc/en-us/community/posts/360001212999/comments/360000277280 – Mr-IDE Dec 13 '18 at 13:16
  • 1
    @KhalilAlHooti: See the answer by "debugging XD", especially the PyCharm Terminal way. – Franc Drobnič Mar 29 '19 at 21:45
5

The shortest way I found:
If you type jupyter notebook in a PowerShell terminal, PowerShell will automatically print out the localhost, port, and token that PyCharm needs to run.

You can run the command from PyCharm Terminal so it will go to the same interpreter if you have several.

Eli Safra
  • 113
  • 1
  • 3
Sam Al-Ghammari
  • 1,021
  • 7
  • 23
3

For the people like me, who don't know where is the terminal ->Another way which I find easier is:

1) open new Jupyter notebook in your browser. Look at the URL, there you can see your localhost (example: localhost:8889) and change the default one at PyCharm if necessary.

2) for the token, while you are in the browser press F12 and then Ctrl + F and search for 'token'. It would be somewhere there in the html code, a long string of random numbers and letters.

Finrod Felagund
  • 1,231
  • 2
  • 14
  • 18
1
  1. Run Anaconda Navigator
  2. Create Or Open New Notebook
  3. Press F12 Or Inspect Element
  4. Search For 'token' in its html code
  5. You Can Find something like this : 'data-jupyter-api-token="02eaf15f7fb715725c85602867d0b2585962e0ee...."'
saeed eivazi
  • 818
  • 1
  • 7
  • 14
1

I had to reinstall Anaconda and some old config files for my Jupyter Notebook. Check for possible existing jupyter config file, that could contain a password or Token in some cases:

  • open terminal

  • Check for jupyter configuration directory:

    jupyter --config-dir

    (example output)>>> C:\Users\Username.jupyter

open the file and check if "NotebookApp" is assigned in the file:

{
  "NotebookApp": {
    "password": "sha1:1af4568a9g:64gsded68g4dsh434df634fhd684"
  }
}