How can I run my Python file using PyCharm terminal? [duplicate] - python

This question already has answers here:
How to execute Python scripts in Windows?
(9 answers)
Closed 1 year ago.
I tried to update my PyCharm but it got corrupted so I had to reinstall the program, since doing so I lost my previous settings.
Before, I used to be able to enter a file name into the Terminal (Not Python Console) and the code would run.
E.g I have a file named code.py, I could enter 'code' and it would run and print the statement.
print("Hello World")
But now when I try this, the Terminal returns no print statement output and simply opens up the code.py tab on PyCharm. What settings do I need to change? I have included a screenshot.

Open the terminal and type:
python code.py

i hope you already know how to open a terminal in pycharm so after doing that simply run the command that you want to run your code with, in this case it will be:
python code.py

Related

I get nothing when use input function on python 3.6 [duplicate]

This question already has answers here:
Can't send input to running program in Sublime Text
(5 answers)
Closed 3 years ago.
I am trying something very simple but my code just stuck or it is a problem with the print input function. So this is my code
variable = input("Enter something: ")
print(variable)
When I run my script e get nothing. This is the output:
Enter something: try
And it just stuck. Nothing is printed. I do not know what is the problem and do not think that there is a coding problem.
Sublime text 3 has some build problems with its command palette. I just tried this code with sublime and faced the same problem.
Use command prompt(if windows) or terminal(if linux) with following command:
python <filename>.py
Or open this file with python IDLE and use F5 key to run the script.

What happened after entered " flask run" on a terminal under the project directory? [duplicate]

This question already has answers here:
Explain Python entry points?
(3 answers)
Closed 3 years ago.
What happened after entered "flask run" on a terminal under the project directory?
How the python interpreter gets the file of flask.__main__.py and starts running project's code?
I know how Flask locates app. What I want to figure out is how command line instruction "flask run" get the flask/__main__.py bootup
flask is a Python script. Since you stated you are not a beginner, you should simply open the file (/usr/bin/flask) in your favorite text editor and start from there. There is no magic under the hood.
To run the application you can either use the flask command or python’s -m switch with Flask. Before you can do that you need to tell your terminal the application to work with by exporting the FLASK_APP environment variable:
Imp - This launches a very simple builtin server.
Please read it :- http://flask.pocoo.org/docs/0.12/quickstart/

unexpected character after line continuation character when opening file in command line [duplicate]

This question already has answers here:
syntax error when using command line in python
(7 answers)
Closed 4 years ago.
I have just started learning python and make a python file called "helloworld.py" and store it inside a file called "python py" on the desktop, but this keep poping out whenever I am trying to open it in command line like this:
Can someone tell me what's wrong?
You are in a python shell (we can see that from >>>). Try starting cmd.exe and then run your same command:
python helloworld.py
(from the same path as the helloworld.py file).
When you run Python.exe (as you did), you can not run scripts. This is just for running commands "live". In your shell, try for example print(1). It should work.

How to configure in .vimrc , execute current file python f9? [duplicate]

This question already has answers here:
Running Python code in Vim
(25 answers)
Closed 5 years ago.
I'm newbie in this editor but it's complex to configure vimrc. I know and understand that everything stay there but I don't understand how to configure, specifically the code. On the other hand, I am writing Python code using Vim. Every time I want to run my code, I type this inside Vim
:w !python
This gets frustrating, so I was looking for a quicker method to run Python code inside Vim. If somebody can I help me, I would be very grateful.
You've very close. The following works in my config:
nnoremap <F9> :w<cr>:!python %<cr>
First, it enters the command to save the file (:w). Then it tells the shell to have python (!python) run the current file (%).

Running Python With Notepad++ [duplicate]

This question already has answers here:
How to Execute a Python Script in Notepad++?
(21 answers)
Closed 5 years ago.
I have notepad++ version v6.9.1 and python 3.5 (32 bit). Running Windows 10. I need to be able to run my python code, but when I try to download the PyNPP plugin (this is what I use at school) it gives me and error message saying the it isn't compatible with the version of NPP.
You don't need a plugin to run Python code from NotePad++.
Just press F5 and then depending on the location of Python you will type:
C:\Python32\python.exe "$(FULL_CURRENT_PATH)"
Of course, you will have to replace C:\Python32\python.exe with the location of your Python installation.
You can also save this as a keyboard shortcut, just click save, and input the keyboard shortcut you would like to use.

Categories