PyCharm: Why are only exit code lines displayed? - python

For example, running the following line of code:
print("Hello, world! My name is Enkouyami")
Only outputs this:
Process finished with exit code 0
The only way to get it to display that text is to go to the python console.

My AV Program was pausing the installer and the Pycharm application, asking me if I want to allow the program to perform certain actions. Even though I allowed it, it messed up my Pycharm setup. Reinstalling Pycharm fixed the problem.

Related

VS Code had a problem in running the code

I tried to run a python program in VS Code. But my program didn't run. The terminal opened and a weird arrow was there in the terminal. This is the screenshot of that.
This is the weird arrow and the program is not running. Any ideas why this is happening and how to fix it?
Thanks in advance.
Firstly, the arrows are included in the default python IDE means that VScode ran the command to execute your code. Give your pc a restart. Now, let us check if python is working or not or VS code is having some trouble. Type the following command in cmd to execute the code-
python "$PATH"
Rember to replace $PATH to the path of the file i.e where your file is stored. For eg. I've my python files stored in D drive in a python folder, so I'll use-
python "D:\Python\Hello.py"
If this works, python is working fine and if not, try reinstalling python and check the box which says Add python to Path or Environment variables. Then open VS code try to run the program again. But click the button only once and be patient because clicking it multiple times causes execute the same command again and cause a problem. It's my personal experience. Wait 5 minutes. Not works. Don't worry, there's a problem with the run extension you are using. I'll recommend the Code runner by Jun han. I personally use it. Type this in the extension search box-
formulahendry.code-runner
Install it and then try again.
Kill the terminal, and retry. If not work, restart the VSCode.

Visual Studio Code: The terminal process terminated with exit code: {0}

I just installed VSC and did a 2 line code as per the tutorial:
msg = "Hello World"
print(msg)
when running the code, the following error message is displayed:
The terminal process terminated with exit code: {0}
If I click on the terminal menu, and then new terminal, it briefly appears and vanishes with same error message.
Try running the program by pushing the green arrow in Visual Studio Code. I think what you’re seeing is that the code completes and the terminal closes. It’s not waiting for you to do anything, so it’s finished.
Assuming you’re in Windows, the easiest way to get around this is to run the code within the Visual Studio itself.
Another handy way to use PowerShell. Open PowerShell. Navigate to the directory were you have saved the program and type “python yourfilename.py”. The program will still end quickly, but you will be able to see what it printed.
Finally, you can use Python IDLE. IDLE is an IDE, like VS Code, but specifically for Python. You can open your program with IDLE and it will display the results in a similar way that it would appear in PowerShell.
There are a lot of different options. It’s confusing when you’re first trying to get your bearings. You’ll find something that feels good for you.

How to see which part of the code is running in terminal

When you run a python script from terminal and before it completes running of you control + c it, it gives a traceback where the code was currently running. Is it possible to see which part of a code is running without terminating it.
in pycharm, you can debug by selecting code areas that you want to work, and by pressing next and next, you'll see how does program running it, without terminating it.
You can do this in PyCharm using the debugging facility. It allows you to step through your code line by line, running each line as you pass it. You can see what variables have been assigned etc. Very helpful for debugging!
See here: https://www.jetbrains.com/help/pycharm/part-1-debugging-python-code.html

Sublime Text Keep Executing Python.exe After Build is Cancelled

Greetings dear community,
I am currently using Sublime Text 2 (Unregistered) as my coding agent. And there is a strange behavior i noticed lately. When i am running a code in sublime text(Through build, with CTRL-B), if a code needs long time to run, like an infinite loop, I try to cancel the build(I specified CTRL-SHIFT-B to cancel build), sublime text shows me a message that build is cancelled
[Cancelled]
like so. In regular command line this means python program is no longer running. As I think it should be the same in sublime text, however, it is not. As longer i keep trying to cancel than build again, more and more python.exe keeps showing in the task manager. I can have like 10 python.exe running behind if I don't end process manually through task manager. Can somebody explain this behavior to me please ? And the reason behind it, can I prevent it ?
By the way, I tested the Python IDLE, and command prompt before asking so i could provide more information
Python IDLE shows same behavior and keeps python exe's running after cancelling.
Command prompt stops the process with no problem.
I am using python2 in a windows 8.1 system.
Thanks in advance for your time.

Python access violation

Here is a Python 3.4 user, in VS 2013 and PTVS...
I'd written a program to plot something by Matplotlib... The output had been generating and everything was ok...
So, I closed VS and now I've opened it again after an hour, running the very script, but this time as soon as I press F5, a window appears and says Python has stopped working...
There is a short log in the output window, which asserts that:
The program '[9952] python.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.
Who could decrypt this error, please?!...
Kind Regards
.........................................
Edit:
I just tested again with no change... The error has been changed to:
The program '[11284] python.exe' has exited with code -1073741819 (0xc0000005) 'Access violation'.
Debug shows that when the program points to the drawing command of the matloptlib, i.e. plt.show(), this crash will happen...
All of the attempts sounds futile...
Even removing the VS is a challenging stuff... and as people consider, changing the OS is the most stable way to get rid of VS in the presence of such anomalies regarding its libraries...
So... I changed the OS... and installed the VS and PTVS again...
It seems to be a problem with your python and PTVS. Try to remove every .pyc file and have another go at it

Categories