Running python in vscode terminal - python

I want to run python on vscode terminal but when i try to do so i get the following:
I use the code runner extension and i am enabling 'run code in terminal'option.
It used to work for me, but i have tried recently to run python on windows terminal by copying the entire thing vscode generates in it's terminal when building the executable(the path and everything) and pasting it to windows terminal, didn't work.
This is what i pasted: C:\Users\Yan\AppData\Local\tmc\vscode\mooc-programming-22\part05-27_letter_square> python -u "c:\Users\Yan\AppData\Local\tmc\vscode\mooc-programming-22\part05-27_letter_square\src\letter_square.py"
Please tell how to fix this and if what i did is the cause, then tell me also how to run python on windows terminal without causing this problem.

The command pasted to the windows terminal has somehow created a file named "python" (with no extension) in the "System32" folder.
Delete the file and the problem is solved.

Related

VSCode on Mac OS Monterey running python code to terminal instead of printing in output

I installed VSCode through Homebrew and I'm writing a basic program. Anything I try to print prints to the terminal instead of output. I have no coderunner settings that I can find based on other questions similar to this
Tried to reinstall without homebrew, same issue. Anything I print prints to terminal and not output
How did you run the python file?
You can use Run Python File button directly, you'll get the output in terminal.
If you use Run Code button, this is a function provided by code-runner extension. You have to add the following code to settings.json(Use shortcuts "Ctrl+Shift+P" and search for Preference: Open User Settings) so that file will be run in terminal:
"code-runner.runInTerminal": true,

Python3 installed, but why can't I run python file in terminal

I am trying to run a python3 file out of the directory the file is located in on macOS catalina.
so I type the following:
python3 <file_name>
and nothing happens in my terminal, it just starts a new line in the same directory, but no file runs.
Up until now I have only ever used a jupyter notebook to run python, but now I am trying to run VS code and run the file inside of the terminal.
Anyone know how to fix?
I just wanted to say I fixed the problem trying a number of different solutions:
I downloaded the most recent version of python, ran certificates and update commands.
I selected the new python interpreter from VS code using shift+cmd+P and select interpreter option.
I ran the file in python launcher and then again in terminal and it works fine now. Thanks for participating in helping me solve this issue.
Alternatively if anyone else has similar problems, try the steps I mentioned, or maybe try setting up a pyenv to run python files in a virtual python environment.

Python code not running in terminal in VS Code or PyCharm

I'm new to programming, I've started Python with VS code and Pycharm, and I can't run my code in terminal or output tab. I've followed the steps in installing python and configuring the interpreter but i cant fix this.
This is what i get in VS Code
This is what i get in PyCharm
Open your command prompt by going to windows search bar and searching for it.
then enter cd "path of your folder" and press enter.Now you are in your project folder.
Now run the command "python app.py" where app.py is the name of your app.
Also please upload your code for more clarification on your question.

Pyinstaller on Linux - How to show a console

I'm trying to generate a Python executable file with Pyinstaller on Linux. For this purpose I'm trying this implementation with a simple 'Hello World' file.
The issue I'm having is that when the executable file is generated and I execute it (double-click), nothing happens. There is no console popping out and I can see no execution. I have read in the documentation that in MacOS and Windows there are explicit options in order to make this console appear or not, but not in Linux.
Any idea?
You should open your console, and use "python file.py" or "python3 file.py" command (it depends on Python version), where file.py is your file.
I hope that I helped.

PyCharm cannot call programs from CMD Path

I have a code that needs to call a program from with a CMD command.
When I run the code in Python IDLE, it works, but not on Pycharm.
Here is an example code:
import os
os.system('pip')
This code runs on python IDLE, but on Pycharm it exits with:
'pip' is not recognized as an internal or external command,
operable program or batch file.
I am running it on Windows Server 2012 R2 if that helps.
How can I solve this? Thanks!
#Litwos,
pip should be bundled with your python interpreter - if PyCharm can find your python interpreter, it should be able to find a workable pip. Check that your python interpreter is set properly and PyCharm can find all the bundled tools.
Note: I have to do this for every new project:
Open PyCharm Preferences -> Project -> Project Interpreter
Select an appropriate interpreter
Verify that pip shows in the package list below the Project Interpreter listbox

Categories