在Python中使用PicoSDK

问题描述 投票:0回答:3

我尝试使用 Python 中的 PicoSDK 远程控制我的 picograph ps3000a。我在 Github 上找到了 PicoSDK-Python-Wrapper 项目。但我实际上不知道如何将它嵌入到我的项目中。我可以运行该示例,但当我尝试加载 SDK dll 时,我失败了。

我在我的项目中复制了

setup.py
,当我运行它时,我得到了

Traceback (most recent call last):
  File "picoscope_3000.py", line 16, in <module>
    result = ctypes.WinDLL(find_library('ps3000a'))
  File "C:\Users\ajaeggi\AppData\Local\Programs\Python\Python37\lib\ctypes\__init__.py", line 356, in __init__
    self._handle = _dlopen(self._name, mode)
TypeError: LoadLibrary() argument 1 must be str, not None

那么从原始源运行它有什么区别,我错过了哪些依赖项?

python-3.x dll
3个回答
1
投票

这对于OP来说显然太晚了,但我正在回答以供将来参考:

  1. 通过 USB 将示波器连接到 PC 来安装驱动程序。
  2. 此处为您的设备安装 DLL。
  3. 将安装目录(默认为
    C:\Program Files\Pico Technology\PicoScope 7 T&M Stable
    )添加到环境变量中(开始>输入“环境变量”>单击“环境变量...”>在用户变量中设置$username$、“Path”和“Edit..” ." > 单击“新建”> 添加 DLL 的父路径)。
  4. 重新启动计算机。
  5. 激活您的虚拟环境。
  6. 通过在虚拟环境中运行 picosdk
     直接从 GitHub 安装 
    pip install git+https://github.com/picotech/picosdk-python-wrappers.git
     库。
  7. 通过在脚本中添加
    import picosdk
    来导入库。

祝你好运!


0
投票

尝试进入 setup.py 脚本并删除 try-catch 部分,如下所示:

if not os.path.exists(signalfile):
    name = 'ps2000'
    if sys.platform == 'win32':
        result = ctypes.WinDLL(find_library(name))
    else:
        result = cdll.LoadLibrary(find_library(name))

    open(signalfile, 'a').close()

0
投票

我认为您遇到的问题是由于无法找到 DLL 引起的。遇到同样的问题,我搜索了 ps2000 并找到了该名称的 DLL:

C:\Program Files\Pico Technology\PicoLog
,将其添加到我的路径然后运行
pip install .
后,我得到了以下成功的输出:

    (tc08-3819) PS C:\Users\eklek\projects\eklektek\python\github\picosdk-python-wrappers> pip install .
Processing c:\users\eklek\projects\eklektek\python\github\picosdk-python-wrappers
  Preparing metadata (setup.py) ... done
Collecting numpy>=1.12.1 (from picosdk==1.0)
  Downloading numpy-1.24.4-cp38-cp38-win_amd64.whl.metadata (5.6 kB)
Downloading numpy-1.24.4-cp38-cp38-win_amd64.whl (14.9 MB)
   ---------------------------------------- 14.9/14.9 MB 5.5 MB/s eta 0:00:00
Building wheels for collected packages: picosdk
  Building wheel for picosdk (setup.py) ... done
  Created wheel for picosdk: filename=picosdk-1.0-py3-none-any.whl size=76497 sha256=5fa1f628d9ffdbef8812a93c0277c1f58c58dc49dc31b9fb84be972775be3b90
  Stored in directory: c:\users\eklek\appdata\local\pip\cache\wheels\d6\f5\ce\9511fd5bce8ad8f3612f3fde9300a16ba6abeed88e563f8aaa
Successfully built picosdk
Installing collected packages: numpy, picosdk
Successfully installed numpy-1.24.4 picosdk-1.0
(tc08-3819) PS C:\Users\eklek\projects\eklektek\python\github\picosdk-python-wrappers> python
Python 3.8.19 (default, Mar 20 2024, 19:55:45) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.

这是使用 python 3.8.19 的 conda 环境

© www.soinside.com 2019 - 2024. All rights reserved.