0

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.

Terminal not running code

bad_coder
  • 11,289
  • 20
  • 44
  • 72
  • You might be mixing several ways of executing a module/script. A complete reference can be found in [*"1.1. Command line"*](https://docs.python.org/3/using/cmdline.html#command-line). Since you have a `main.py` (could easily be `__main__.py`) check the section on executing packages. In any case, executing a module without the `.py` extension can happen if you installed your project as a library and an `.exe` is created for your module. It could be you had the OS configured to execute `.py` files by transparently associating them to Python. – bad_coder Mar 21 '21 at 06:06

2 Answers2

1

Open the terminal and type:

python code.py
Rithwik Babu
  • 104
  • 1
  • 6
0

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