You may check outthis question.You were not able to run python file on bash is because you are not running program the correct way. Let me explain, bash is the usual terminal. VSCode uses bash as well .
How to run a python file on a bash terminal in Vscode
- Open VS Code: Launch Visual Studio Code on your system.
- Open Python File: Open the Python file you want to run within VS Code. You can either navigate to the file using the file explorer on the left sidebar or use the
File
->Open File.
then you will see a menu option. - Open Terminal: Once you have the Python file open, you can open a terminal within VS Code. You can do this by selecting the
Terminal
->New Terminal
menu option, or by pressing Ctrl + Shift + , which is the back-tick character on most keyboards. - Navigate to Python File Directory: If your Python file is not already in the current working directory of the terminal, you’ll need to navigate to the directory containing your Python file using the
cd
command. - Run Python File: Once you’re in the correct directory, you can run your Python file using the Python interpreter. Simply type
python <filename.py>
in the terminal and pressEnter
. Remember to<filename.py>
with the actual name of your Python file.
python myscript.py
or you can use another option
python3 myscript.py
bash$ python(3)
>>> from file import x
>>> x()
or run it from the file itself.
def x():
...
x()
Monitor your output to see the run python file on a bash terminal in Vscode
Why is django uploads class-based_view not seeing my uploads?