2
$\begingroup$

In Jupyter Notebook I have blocks of Python code and I can run them arbitrarily. What is super cool about that is I can spend 10 minutes training some ML model and then play around with it, without the need to run the training process again and again.

How can I achieve something similar using PyCharm? While I like this feature in Jupyter it is so less convenient to write code.

$\endgroup$

2 Answers 2

2
$\begingroup$

Pycharm allows you to highlight a section of run and execute that specific section in the console by right-clicking and choosing 'Execute selection in Python Console'. This section of code has now been executed and any variables you've defined are now stored in memory.

You can continue executing pieces of code in this way and reference objects previously created up until you refresh the console session.

$\endgroup$
1
$\begingroup$

@qriouscat answer is correct.

Additionally, I found a great plugin - PyCharm cell mode - which allows to define blocks of code and run them like in a Jupyter.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.