简体   繁体   中英

How to run standalone files in PyCharm

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM