I'm new to python and pycharm and I'd like to run a module from the pycharm console in the same way as you can from IDLE, if it's possible.
The idea is to create simple functions and test them "live" using the console.
...how do you do that in pycharm?
Choose Run | Run from the main menu or press Alt+Shift+F10 , and then select the desired run/debug configuration.
Go to File -> Settings (or Default Settings) -> Build, Execution, Deployment -> Console -> Python Console. Now I can import modules inside the source roots in the console!
To run Python scripts with the python command, you need to open a command-line and type in the word python , or python3 if you have both versions, followed by the path to your script, just like this: $ python3 hello.py Hello World!
Alt + Shift + F10 and then select the script you want to run. After that Shift + F10 will run the last script that has been run.
Running python scripts using pycharm is pretty straightforward, quote from docs:
To run a script with a temporary run/debug configuration Open the desired script in the editor, or select it in the Project tool window. Choose Run on the context menu, or press Ctrl+Shift+F10. So doing, a temporary run/debug configuration is created on-the-fly.
Besides there is a "Python Console" available in pycharm: see documentation.
UPD: Here's an example.
Imagine you have a python module called test_module.py
:
def a(*args, **kwargs): print "I'm function a" def b(*args, **kwargs): print "I'm function b"
Then, in pycharm's "Python Console" you can do this:
>>> from test_module import * >>> a() I'm function a >>> b() I'm function b
If you need to execute a part of an existing code, you can use the Execute Selection in Console feature: select the code snippet -> right click -> "Execute Selection in Console".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With