Reputation: 43
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?
Upvotes: 2
Views: 2792
Reputation: 675
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?
Upvotes: 3