Matplotlib image not coming up in Visual Studio Code on Mac

前端 未结 2 724
天涯浪人
天涯浪人 2021-01-13 04:28

I\'m running some basic code in the Visual Studio Code editor on MacOSX:

    import matplotlib.pyplot as plt
    import numpy as np
    x = np.linspace(0, 20         


        
2条回答
  •  不要未来只要你来
    2021-01-13 05:16

    I faced the same issue and here's what I did to solve it.

    Since the code runs without any error but also does not generate any plot and needs to be terminated manually, it's difficult to figure out what's going on. I tried running python2.7 test.py This works, plot is generated but python3 test.py does not work.

    So, here's what you need to do -

    Run, pip install matplotlib --upgrade to upgrade the matplotlib. This does not resolve the issue but now the error is printed.

    "RuntimeError: Python is not installed as a framework" ......

    So, finally, to solve the problem, refer to Working with Matplotlib on macOS

    Since, I am using Anaconda, all I need to do is conda install python.app and then use pythonw to run all scripts. I hope you also find the solution to your particular case from the FAQ.

    Overall, it's a Matplotlib problem, so upgrading (or reinstalling) and trying with different Python versions should get you going.

提交回复
热议问题