Lucas Myers
Lucas Myers

Reputation: 404

Getting rid of black console windows when running sympy through spyder

Whenever I try to display symbolic math in Spyder via the IPython console, several black console windows pop up and then disappear in quick succession. It prints the expression, but I'd like to know if there is a way to get rid of these windows. The windows have the title "C:\Program Files\MikTex 2.9..." if that helps.

Upvotes: 1

Views: 521

Answers (2)

Carlos Cordoba
Carlos Cordoba

Reputation: 34156

I submitted a pull request to fix this for good:

https://github.com/sympy/sympy/pull/12391

Upvotes: 1

Lucas Myers
Lucas Myers

Reputation: 404

It looks like someone already figured it out and posted a solution on GitHub. This is the link: https://github.com/sympy/sympy/issues/11882

It took me (as a novice) some time to figure out exactly what he did, so the following is just a more detailed explanation:

You first need to find the compatibility module in the sympy package. For me, it was located at "C:\Users\Lucas\Anaconda3\Lib\site-packages\sympy\core\compatibility.py". Next, you need to search (in the source code of that module) for the check_output function. The surrounding code should look something like:

# check_output() is new in Python 2.7
import os

try:
    try:
        from subprocess import check_output

Finally, you need to get rid of the last line, and replace it with the code found in the GitHub link. The resulting block should look like:

# check_output() is new in Python 2.7
import os

try:
    try:
        from subprocess import check_output as subprocess_check_output
        def check_output(*args, **kwargs):
            return subprocess_check_output(*args, **kwargs, creationflags=0x08000000) # CREATE_NO_WINDOW

It appears to me that he defines a function which takes the place of check_output, except that the argument to suppress the output windows is always fed in. Hope this helps anyone else having this problem, and I appreciate the fix from Adam on GitHub.

Upvotes: 2

Related Questions