I have an aesthetic problem with my VSCode terminal. On this picture you can see, that whenever I try to run my code, terminal also displays information about the directory folder. It's annoying and completely useless to me... Is there a way to modify terminal settings, so that this shit is not displayed? After running the code I only want to see the result - in this case words "hellow world".
In some guides I've seen people having it that way, however I can't do it.
System: MacOs; Python 3.X
Thanks in advance!
Related
I recently started using Python on VScode and I have been having problems with my output.The code runs smoothly(no problems detected) but the result doesnt appear in my output.The problem isnt with my code because even a simple command like print("Hello world") doesnt appear.
Can someone help me?
Here are some screenshots
Also I tried running the program from another terminal but I had to save the file,for exapmple dna.py, and the system wont let me.An error message appears saying it this file is not supported by .ipynb support and the name should match this pattern .ipynd(tried it,still wont accept it)
The code that I created
The image in my ouput after I run the code
I suggest reviewing the official Visual Studio Code Python documentation and tutorial.
Also, try to run the file directly in a terminal and see if it solves your problem.
ex: python my_script.py
See this answer for more details.
First of all, I started using Python with Eclipse and I didn't like it much. I looked into VS Code since so many people said it was great for Python development. The thing is like it a lot except for the fact that Eclipse showed in the terminal whatever the program I wrote said. However, VS Code also shows lots of unnecessary file paths.
Given a simple instruction such as a print I get vastly different outputs in the terminal depending if I'm using Eclipse or VS Code.
print(2+2)
This is what I get with VS Code, as you can see, the actual result I wanna see is after all those unnecessary file paths.
PS C:\Users\manue\Desktop\Uni\FP\Code> c:; cd 'c:\Users\manue\Desktop\Uni\FP\Code'; & 'C:\Users\manue\miniconda3\python.exe' 'c:\Users\manue\.vscode\extensions\ms-python.python-2021.10.1336267007\pythonFiles\lib\python\debugpy\launcher' '60771' '--' 'c:\Users\manue\Desktop\Uni\FP\Code\15_Oct\prueba.py' 4
Whereas in Eclipse I get just the 4 as I'd expect it to be. I tried modifying the launch.json file but somehow it doesn't work. I also tried with an extension called Code Runner which is super useful (only shows the actual output) but it doesn't let me do input statements. If I change the settings and let Code Runner run in the terminal it allows me to use input statements but there is a catch.
PS C:\Users\manue\Desktop\Uni\FP\Code\15_Oct> cd "c:\Users\manue\Desktop\Uni\FP\Code\15_Oct"
PS C:\Users\manue\Desktop\Uni\FP\Code\15_Oct> python -u "c:\Users\manue\Desktop\Uni\FP\Code\15_Oct\prueba.py"
4
The first output shows some file paths (I'm ok with it since it isn't overwhelming) but as I run my program more times, the gap between each line gets bigger. See this picture
Any suggestions would be gladly appreciated. Thanks
You can modify "console" in the launch.json to "internalConsole":
"console": "internalConsole",
Then you can get the output at the DEBUG CONSOLE panel:
But, it's suggested to get used to the debug Infos in the terminal, they can let you know what exactly going on in the VSCode.
I'm a noob in computer programming, today i installed vscode to learn python, everything was right, i run short and simple lines of code installed some extensions, but i dont know what happened, I'm not sure if i changed some configuration but when i try to run little lines of code (with the button) instead of running it and showing it to me in the "terminal section", it sends me to the "output" section and it just says that the code already run and its done.
Do somebody knows how to solve it please, it really makes me sad that i just ruined this program because its my first day and this already screw it.
As you can see in the picture, i run the code and it shows off something different in the output section, i wrote that but later changed it. It seem like it runs the file but only when i save it. :(
You must save the file to get the new output everytime.
For running code in Terminal with the button -
It looks like you are using Code Runner vscode extension. Which by default uses Output section to show output and cannot take input. You can change this behavior of that extension by pressing ctrl + , and going into vscode settings. Then just search code runner run in terminal You'll see an option to enable Run in Terminal feature turn that on.
I have just written a bunch of lines of code on the Python prompt at the terminal. Now, I want to save all those lines of code to a .py file.
I am unable to find out how to do that. The only thing that I could find on StackOverflow was this answer but it shows only how to do it in an iPython notebook. I am not using an iPython notebook. I am running the code at the command line on the terminal.
I tried to follow that answer (because just in case) and ran the %save magic command on the terminal but it gave a SyntaxError.
So, how do save it?
Thanks!
See http://blog.e-shell.org/174 . As wu explains, the python prompt is using readline, and you can import a Python library to access this.
>>> import readline
>>> readline.write_history_file('/path/to/history.txt')
You can trying using another interpreter : bpython , I belive it has what you need,check it out.
Save the code you've entered to a file.
You seem to be affected by the misconception, that the python environment is workspace-centered (similar to what I know from Smalltalk and some LISP variants):
fire up with an initial workspace
modify by your liking
store the result
This is unfortunately not the case. While you can import existing files, the other option is to specify an existing file as initially to be loaded and keep the interpreter open by using the -i option.
It really depends on your terminal for the exact commands.
The general idea is to copy everything (if possible) or one page at a time from the terminal into a text editor and then clean the >>> prompts (and possibly other formatting problems) in the text editor.
But anyway, typing a lot of commands directly in the execution environment if really bad practice. At least you test a handful of lines and immediately save them in a file. IDLE is great at this game...
I have a simple question. I am in the process of debugging some code. I am using Enthought Python, with the "PyLab" program. I edit my code using gEdit. I am using Ubuntu 10.04.4 LTS.
I use "run myfile.py" to run the program. Then I test myfile(somearguments), and see where the bugs are.
However, when I make changes to the code, using "run myfile.py" again does not properly update what Python/PyLab on the changes to my code. The result is that I will get error messages back pointing to lines that have no errors, and don't even have the "trouble" text in them anymore. I tried using import and reload as well, but that didn't work.
How do I get Python/PyLab to see the new changes to my code? The only option I have for now is to fix the bug and then restart PyLab to confirm the fix.
Thanks!
Did you try to remove the pyc file ?
It may happen as the pyc file exists that PyLab keeps reading it without reloading the file.