0

I can't find the command prompt for Python. I used to use it as my primary calculator on windows 10. I only have idle and the IDE. I just made a small program in Python, but it won't run it in a command prompt! When I click on it, it just opens its source code. The only way to run it is to use the test run feature. I tried to run it through the terminal, but it just keeps telling me it can't find the file.

Why can't I get python's command prompt to come up? Is it not a feature in Ubuntu? Why would that be? That makes no sense. Python is installed, so why can't you run python programs? If I can't do that, I can't see myself using Ubuntu.

user8600
  • 147
  • Running Python on Windows probably requires CMD.exe somewhere, so you get a console window as a side effect. Running Python on Linux doesn't need any terminal. All you need is an executable script file. But it will be run using Python and without any terminal involved, which is probably not what you need. You'll need something like this to run a script in a terminal when you click on it: https://askubuntu.com/a/601291/158442 – muru Dec 15 '23 at 03:14
  • Yes it is actually; I don't want my programs to run through the stupid idle, and I don't like having to click 3 to 5 buttons just to open one file! On windows 10, I could just click the program and have it run with no fuss. I thought Ubuntu was going to be an upgrade from windows, but its turning out to be more limited. I can't even handle programs MADE FOR LINUX as well as windows 10 could WITH AN SSHD DRIVE. Wtf? I'd prefer to get answers to my new question regarding that btw; I want to know if my computer can be salvaged at this point. – user8600 Dec 15 '23 at 03:17
  • 1
    Your description is too vague to discern what you might be doing wrong. Keep in mind that we are not in the room with you. We cannot see what you are doing. We know only what you tell us, so please edit your question to provide clear, step-by-step instructions for us to duplicate what you are seeing. The rambling complaints and rhetorical questions distract more than they help. – user535733 Dec 15 '23 at 04:47
  • Uh, I'm not being 'vague'. Python had its own 'console', which I even had a shortcut to on my taskbar! When you run a program, it runs in that instead of the 'idle'. It even had separate settings from window's command prompt, as if it was an independent program. You could type in math formulas into the thing like a command-line calcualtor, which you couldn't do with the prompt windows came with (well, I've heard you can, but you need to type everything in the prorprietary language windows is coded in). This isn't some weird program; it comes standard with python. – user8600 Dec 15 '23 at 09:31
  • I even have it on my laptop here, which still runs windows 10. I didn't have to install it separately; it came with base python, just as much as the random and math modules. How could you possibly not know what it is? On Ubuntu, like I said all I have is the IDE and the idle. The only thing I ever used the idle for in the past was so I could see error messages. A program being run through the prompt just crashes if it encounters an error. – user8600 Dec 15 '23 at 09:33
  • 1
    ... open a terminal emulator window and type python3 – steeldriver Dec 15 '23 at 12:12
  • Uh, what's that? I know about the terminal, but what do you mean by 'terminal emulator'? I haven't installed any emulators other than proton, mainly because I can't get this thing to download Wine from anywhere it seems. I did find a console command meant for Ubuntu 20, but it just throws an error message saying the command makes no sense. – user8600 Dec 15 '23 at 12:17
  • At no point in time has Python had it's own console, unless you're talking about IDLE. – muru Dec 15 '23 at 14:08
  • Then why does mine? I can open it AND the windows console at the same time, along with idle, and python's IDE! If its not a distinct program that comes with python, then what is it that I'm actually pulling up? On a side note, I decided to transfer from pygame programs from this laptop to it, hoping they would at least work. They technically do, but like python programs they don't run automatically; I can only run them by using the test run feature from the IDE. What the fuck? Why would Ubuntu come with python but not the ability to run them from outside the IDE? – user8600 Dec 15 '23 at 18:38

1 Answers1

1

A better way to run Python code from the terminal in Ubuntu is to install the python3-ipython package. ipython3 is an enhanced interactive Python 3 shell that allows you to copy/paste a line of Python code or a Python code block into the terminal and run it interactively.

To install python3-ipython in all currently supported versions of Ubuntu open the terminal and type:

sudo apt install python3-ipython

To start the ipython3 interpreter type ipython3 and to exit from the ipython3 interpreter type exit

karel
  • 114,770