OS: Windows 11 (64 bit)
Python version: 3.12.0 (64 bit)
Emacs version: 29.1
I use LSP mode in Emacs for Python programming and I have in my Emacs init.el file the following:
(custom-set-variables
. . .
'(python-shell-interpreter "python"))
The above code allows Emacs to detect the correct Python interpreter, that is, the current running virtual environment. As a matter of fact, I always activate in a command line my desired Python virtual environment, then I run Emacs from the very terminal as a background process. This way, Emacs detects automatically the current running Python virtual environment.
This works, except that Python inferior buffer doesn't seem to work properly or maybe it's just me who doesn't understand how this buffer functions. Consider the following Python program:
def main():
"""Print Hello."""
print("Hello World", flush=True)
if __name__ == "__main__":
main()
First I run C-c C-p to start a Python process (therefore a inferior Python buffer in Emacs) and then I run C-c C-c to send the entire buffer containing the above-mentioned program to Python. The problem is, no output, no "Hello world" is printed, only a new prompt line >>> is appended to the inferior Python. However, if there is an error in the program, let's say for example a syntax error, then the corresponding error message is printed after C-c C-c in inferior Python buffer.
I don't understand why error messages are printed but not the program's output? Do I need to add some configuration in my Emacs init.el file ?