This content is not available in your preferred language.

The content is shown in another available language. Your browser may include features that can help translate the text.

DIAdem/SystemLinkでmatplotlib.pyplot.plt()メソッドが実行するとエラーが発生する

更新しました Apr 8, 2021

使用製品

ソフトウェア

  • DIAdem
  • SystemLink

問題

DIAdemとPython 3.7を使用してmatplotlibのpyplot.pltを実行すると下記のエラーが発生します。

File "C:\Program Files\National Instruments\Shared\Skyline\Python\3.7\lib\tkinter\__init__.py", line 2018, in __init__
baseName = os.path.basename(sys.argv[0])
IndexError: list index out of range


VisualStudio Code等では下記の様なコードを問題なく実行できるのですが、DIAdem/SystemLinkで実行する方法はありませんか?
 
import matplotlib.pyplot as plt
x = [100, 200, 300, 400, 500, 600]
y = [10, 20, 30, 50, 80, 130]
plt.plot(x, y)
plt.show()

解決策

DIAdem/SystemLinkではPythonが埋め込まれておりますがこれらはコンソールアプリケーションではない為、argvのようなコマンドラインパラメータは空のままです。下記のコードを追加する事でエラーの回避ができます。
 
import sys
sys.argv=["DIAdem"]
EmbMatplotlib.png