Error when .py file run in CudaText

anilanthikad
Posts: 5
Joined: 22.07.2022 12:03

Error when .py file run in CudaText

Post by anilanthikad »

Hello,
My name is Anil, about 50 years old from India, I am not a programmer yet. I failed 8 times trying to learn Python lol. But still not giving up.
I was a Graphic designer/Creative Director with 26 yrs of exp. But Covid lockdowns destroyed my life, so i started to learn coding.

I stopped using MS Windows and any corporate softwares.
Currently using Pop! OS as my operating system.

Previously i have tried using VSCodium and PyCharm, they are very heavy software. So i was searching for lightweight alternative. And found CudaText and Kate(not using Kate now).
I should admit its not as intuitive to learn how to work in CudaText. But again I am not giving up.

So coming to the support request...

I've attached two screenshot of a very simple python file, same file run in CudaText and in VSCodium.
In VSCodium its runs fine, but not in CudaText; it gives Error massage.

Could anyone please let me know what I am doing wrong in CudaText?
I would love to continue learning CudaText.

Looking for a reply at the earliest,
Thank you in Advance,
Attachments
Codium output
Codium output
CudaText output
CudaText output
main Alexey
Posts: 2300
Joined: 25.08.2021 18:15

Post by main Alexey »

I see you are using ExternalTools plugin which is not fully OK here - you use 'input()' function which will be not good for ExtTools plugin.
so, use plugin ExTerminal instead.
here are my steps to work with your example.

- create file ~/tt.py with code:

Code: Select all

x=int(input('enter x: '))
w=int(input('enter w: '))
print(x*w)
- (restart CudaText after installing ExTerminal)
- call ExTerminal by clicking its bottom-bar-icon
- in ExTerminal, enter "ls" (dir listing) - file tt.py is here. if it's not here, enter "cd FolderName" in ExTerminal.
- in ExTerminal, enter "python3 tt.py" (python3 is usual Linux command) --> it worked OK here and I see 2 input-messages.

It helps?
I use Xubuntu 20.4.
Attachments
exter1.png
main Alexey
Posts: 2300
Joined: 25.08.2021 18:15

Post by main Alexey »

anilanthikad
Posts: 5
Joined: 22.07.2022 12:03

Post by anilanthikad »

Dear Alexey,
Your awesome!
Thank you for such a quick reply.

Your instructions worked perfectly well.

Also in this case please let me seek one more suggestion from you...

I had created a hotkey to run the current open python document. But it'll open only in "Capture output: Output panel".
I've attached a screenshot for your reference.

Is there anyway i can set it to ExTerminal? Currently the Capture output: dropdown menu dont give this option.
Attachments
hotkey for py.png
main Alexey
Posts: 2300
Joined: 25.08.2021 18:15

Post by main Alexey »

No, there is no such option.
There is alternative, Runner:
https://wiki.lazarus.freepascal.org/Cud ... ins#Runner
It also don't have such option.
anilanthikad
Posts: 5
Joined: 22.07.2022 12:03

Post by anilanthikad »

Alright, Thank you again! =)
Hopefully someday, someone could fix that as it would help a lot =)

Cheers!
main Alexey
Posts: 2300
Joined: 25.08.2021 18:15

Post by main Alexey »

ExtTools / ExTerminal are independent plugins. why to put output from 1st to the 2nd? ExtTools puts output to the "Output" panel or to the 'Console' panel. it must be OK. :)
main Alexey
Posts: 2300
Joined: 25.08.2021 18:15

Post by main Alexey »

Another reason: ExTerminal supports N panels at once (you can right-click its sidebar button - then 'New terminal'). so ExtTools cannot know to which panel it can put the text.
anilanthikad
Posts: 5
Joined: 22.07.2022 12:03

Post by anilanthikad »

Ah ok =),
I am understanding a little better why this function is not feasible.

Like i had mentioned in the first post of mine... I am not a techie, I am still struggling to learn python lol.

but just curious... (maybe what i am trying to suggest is really silly, apologies in advance)
What if the hotkey feature was in the core offer of the software rather than plugin's feature, wouldn't that work well?
and with reference to my case, once the hotkey is clicked it runs the code in the current visible terminal at that moment. No matter how many terminals are open.
main Alexey
Posts: 2300
Joined: 25.08.2021 18:15

Post by main Alexey »

Ok, to put in the currently visible terminal - it makes sence. ie makes more sence.

if you are learning python--
1- ExtTools
https://wiki.lazarus.freepascal.org/Cud ... on_scripts
2- Runner
https://wiki.lazarus.freepascal.org/Cud ... for_Python
3- LSP
https://wiki.lazarus.freepascal.org/Cud ... for_Python
or alternative to LSP - 'Python IntelliSense' plg.
Post Reply