Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm 4.0.4 cannot run file, shows 'Run Doctests' in context menu instead

Tags:

python

pycharm

I have copied a .py file from my teacher, and loaded it in to a project in Pycharm 4.04. When i tried to right-click and run it, it shows "Run Doctests in 'foo.py'" instead of the regular "Run 'foo.py'", and i cannot find out how to run it normally.

I searched for 'doctest' in settings and found nothing, and in PyCharm documentation here, there's nothing about disabling doctests either.

I found a similar question here: Pycharm won't allow to run a file. Shows run unittest option only. and tried the suggested solution, but it still showed "Run doctests in 'foo.py'" in context menu.

like image 877
fnlCtrl Avatar asked Feb 19 '15 14:02

fnlCtrl


2 Answers

Just had the same issue. In my case, I had a '>>>' string within the docs of a function:

def foo(x):
    """Do foo.
    Example:
    >>>foo(1)
    # Out: 1
    """
    return x

I had to comment out # >>>foo(1) and delete the run config under Run > Edit Configurations (minus symbol).

like image 87
Darkonaut Avatar answered Nov 10 '22 09:11

Darkonaut


I'm having the same Run 'Doctests in __init__' issue with PyCharm 2016. I'm not sure if this is due to the same problem other people are having, but this is my fix.

I noticed the file that won't run lives in a resource directory:

click here for image

Once I opened a new PyCharm project with the script I want to run not in a resource directory, PyCharm ran it with no problem.

like image 23
Paul W Avatar answered Nov 10 '22 10:11

Paul W