spyder-terminal icon indicating copy to clipboard operation
spyder-terminal copied to clipboard

Run code from .py file in terminal

Open mikeyEcology opened this issue 5 years ago • 2 comments

Description of your problem

Thank you for creating the spyder-terminal software. I'm hoping to find a shortcut, or a button I can press, to directly run code from my .py file in the terminal. It seems the only way I can run my python code in the terminal is to copy from my script file and paste it into the terminal window.

What steps will reproduce the problem? In your .py file type:

  1. python # to open python in terminal
  2. print('hello world') # now within python execute a python command
  3. Run these commands in the terminal

What is the expected output? What do you see instead? I want to be able to run in the terminal in spyder without copying and pasting

Please provide any additional information below Why do I want to run Python commands through the terminal instead of through Python? I'm running on an HPC cluster that I remote into through the terminal and I want to be able to run my Python code line-by-line on the HPC. I have been using RStudio for this functionality because it's the only software I've found that does this, but I'd prefer to be using a Python-based code editor. Thank you.

Versions and main components

  • Terminal Version: 3.2
  • Spyder Version: 4.1.3
  • Python Version: 3.7.6
  • Operating system: macOS 10.14.6

mikeyEcology avatar May 19 '20 19:05 mikeyEcology

@mikeyEcology, nice suggestion! Could you post a screenshot of how this functionality works in RStudio?

ccordoba12 avatar May 19 '20 19:05 ccordoba12

@ccordoba12 Here is what it looks like in my RStudio. To get the code to run in the terminal in RStudio, I press a combination of [Command + alt + Enter] to run the line that I am currently on. Once the line has been sent to the terminal, the cursor moves to the next line. Thank you. Screen Shot 2020-05-19 at 3 46 27 PM

mikeyEcology avatar May 19 '20 19:05 mikeyEcology