以下コードをcx-freezeでEXE化を試みております。
import pyvisa import tkinter as tk frame1 = tk.Tk() frame1.title("USBポート情報確認") frame1.geometry("600x200") def action1(): rm = pyvisa.ResourceManager() visa_list = rm.list_resources() if not len(visa_list)>0: words1.delete(0,tk.END) pass else: words1.delete(0,tk.END) usb_1 = visa_list[0] words1.insert(tk.END,str(usb_1)) print(usb_1) return def action2(): frame1.destroy() return "break" Static1 = tk.Label(frame1,text=u'USB',font=("Menlo", 14)) Static1.place(x=20, y=40) words1 = tk.Entry(frame1,width=40,font=("Menlo", 14)) words1.place(x=110, y=36,height=30) Button1 = tk.Button(frame1,text=u'接続確認',font=("Menlo", 14), width=16,height = 2, command=action1) Button1.place(x=60, y=100) Button1 = tk.Button(frame1,text=u'閉じる',font=("Menlo", 14), width=16,height = 2, command=action2) Button1.place(x=300, y=100) frame1.mainloop()
pyvisaを外したらちゃんとexe化でき、exe化後の実行ファイルのエラーは発生しません。
起動しますが、ボタン1を押すとエラーになる(最初のpyvisaのインポートはうまくできている)
エラーコードは以下です
Exception in Tkinter callback Traceback (most recent call last): File "c:\users\ユーザー名\appdata\local\programs\python\python38-32\lib\tkinter\__init__.py", line 1892, in __call__ return self.func(*args) File "_port.py", line 10, in action1 File "c:\users\ユーザー名\appdata\local\programs\python\python38-32\lib\site-packages\pyvisa\highlevel.py", line 2992, in __new__ visa_library = open_visa_library(visa_library) File "c:\users\ユーザー名\appdata\local\programs\python\python38-32\lib\site-packages\pyvisa\highlevel.py", line 2899, in open_visa_library wrapper = _get_default_wrapper() File "c:\users\ユーザー名\appdata\local\programs\python\python38-32\lib\site-packages\pyvisa\highlevel.py", line 2858, in _get_default_wrapper raise ValueError( ValueError: Could not locate a VISA implementation. Install either the IVI binary or pyvisa-py.
pyvisa-pyはインストールしております。pyファイルではちゃんと実行できております。
環境について、
win10
Python 3.8 32bit
PyVISA 1.12.0
PyVISA-py 0.5.3
cx-Freeze 6.11.1
宜しくお願いいたします。

0 コメント