pyvisa 打包

发布时间:2024年01月20日

pyvisa 打包之后,错误提示:

D:\dwp_backup\python study\communication_instrument_visa\dist>"D:\dwp_backup\python study\communication_instrument_visa\dist\EMI_Test_ok.exe"
Traceback (most recent call last):
? File "EMI_Test_ok.py", line 12, in <module>
ModuleNotFoundError: No module named 'pyvisa'
[63292] Failed to execute script 'EMI_Test_ok' due to unhandled exception!

ValueError: Could not locate a VISA implementation. Install either the IVI binary or pyvisa-py.
[57544] Failed to execute script 'EMI_Test_ok' due to unhandled exception!

解决办法:

  1. 参考如下文章,到NI网站(下面文章有链接)下载NI-VISA驱动,安装NI Visa 驱动。
  2. C:\Windows\System32文件下多出visa.dll
  3. pyinstaller 打包后,运行成功。

How to fix PyVISA ‘ValueError: Could not locate a VISA implementation. Install either the NI binary or pyvisa-py.’

06 Jan, 2024?Guides?0 Comments0

The error message you’re encountering indicates that PyVISA is unable to find a VISA implementation on your system. VISA (Virtual Instrument Software Architecture) is a standard for controlling measurement devices such as oscilloscopes and multimeters. PyVISA provides a Python interface for working with VISA.

There are two common VISA implementations for PyVISA: the National Instruments (NI) VISA library and the pyvisa-py library. The error message suggests that neither of these is installed on your system.

Here’s how you can resolve this issue:

Option 1: Install NI VISA

  1. Install NI-VISA:
  • Download and install the National Instruments VISA library from the official NI website:?NI-VISA Downloads.
  1. Install PyVISA:
  • After installing NI-VISA, you can install PyVISA using pip:
    bash pip install pyvisa

Option 2: Install pyvisa-py

If you don’t want to use the NI VISA library, you can use the pyvisa-py library, a pure Python implementation of VISA.

  1. Install pyvisa-py:
  • Install pyvisa-py using pip:
    bash pip install pyvisa-py
  1. Specify the backend:
  • Once pyvisa-py is installed, you may need to specify the backend explicitly in your Python code or environment. For example:
    python import visa visa.ResourceManager('@py')

Choose one of the options based on your preference and system compatibility. If you are using Windows and have NI hardware, installing NI-VISA is a common choice. If you want a pure Python solution, go for pyvisa-py.

After installing the appropriate VISA implementation, you should no longer encounter the “ValueError: Could not locate a VISA implementation” error.

文章来源:https://blog.csdn.net/qq_47516560/article/details/135693770
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。