I'm doing small time project development using PyCharm. I use Pycharm for its intellisense features. As I develop each piece of code, I like to run it occasionally to test it. All I need at the point of development is to be able to run the file. However, when I right click and try to run a standalone file, PyCharm tries to be intelligent and shows me options to run my code with unit-tests and other fancy testing gimmicks. I don't want to deploy any testing framework at this point.
All I want is to be able to run any file as it is. But somehow, PyCharm is not allowing me to do that for every file.
I will appreciate if someone can provide a workaround for this. I'm using Python 273
Any Python file shown in your folder can be run by right/control clicking on it and selecting in the dropdown menu: Run <name of file without . py> Alternately you can click on the top menu item Run, and in the dropdown menu click on Run... and the current file should appear there. You can click on it.
Run without any previous configuringAny executable script can be run in PyCharm. You don't need to create any run/debug configuration in advance. A temporary run/debug configuration is already created for you.
You need at least one Python installation to be available on your machine. For a new project, PyCharm creates an isolated virtual environment: venv, pipenv, poetry, or Conda. As you work, you can change it or create new interpreters.
You can simply choose the 'Run' entry in the context menu for the file in the Project view:
This will run the file exactly as if you had entered
python
from the command line, in the directory containing the file.
The first time you do this an entry is also added to the toolbar, which allows you to run the file with a single click
and provides options for customizing a range of options supplied automatically each time you run.
I just came across the same problem. It was because it had a class called TestClass in the file. I changed the name of the class and then I was able to run the file as normal.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With