2

I've seen similar posts but haven't seen any reply that really addresses the difference in outputs between Jupyter Notebook and PyCharm.

An example is like this:

from datetime import datetime
now = datetime.now()
now

Output:
Jupyter notebook: datetime.datetime(2019, 12, 8, 13, 20, 37, 339795)

Pycharm: Process finished with exit code 0

There is no output shown in PyCharm. Could someone please explain why there is a difference in the outputs of these two? Any way I can see the same output in PyCharm?

Georgy
  • 12,464
  • 7
  • 65
  • 73
lles
  • 43
  • 4

1 Answers1

3

The reason is because Pycharm is running in script mode, while Jupyter is working in interactive mode. You can add print statements such as print(now) to see the output, or you can run the code in the Pycharm interactive interpreter.

See this for more details on interactive mode Python interpretation difference in interactive mode and script mode

See this for more details on how to use the Pycharm interactive interpreter Does Pycharm have Interactive Python Interpreter?

Slim
  • 648
  • 4
  • 15
  • Thanks Slim - this is helpful! can i please ask the pycharm interpreter mode you are referring to is the pycharm console mode which is also an interactive mode? – lles Dec 08 '19 at 03:14
  • @lles yes "Python Console" and the "Show Python Prompt" in debug mode are both interactive. – Slim Dec 08 '19 at 03:18