Using Python Wrapper

Post general discussions on using our drivers to write your own software here
Post Reply
tsassonx
Newbie
Posts: 0
Joined: Mon Aug 12, 2019 11:33 am

Using Python Wrapper

Post by tsassonx » Mon Aug 12, 2019 11:51 am

Hi,
I managed to run tests using the example which comes with the wrapper.
How can I implement the test in my own project? Am I supposed to copy the whole repo as a directory in my repo?
I seem to need the picosdk package known to my python interpreter.

Thank you

NeilH
PICO STAFF
PICO STAFF
Posts: 181
Joined: Tue Jul 18, 2017 8:28 am

Re: Using Python Wrapper

Post by NeilH » Tue Aug 13, 2019 7:22 am

Hi

You don't need to download the full repository but you will definitely need the picosdk folder from the repository which contains files that define the link between the API functions from the dll and how they are called within python.

Neil
Neil
Technical Support Engineer

tsassonx
Newbie
Posts: 0
Joined: Mon Aug 12, 2019 11:33 am

Re: Using Python Wrapper

Post by tsassonx » Tue Aug 13, 2019 7:55 am

Thanks!
I got it to work, the setup.py file malfunctions, the try...except there does not identify the library so removing it has made me install successfully.

tsassonx
Newbie
Posts: 0
Joined: Mon Aug 12, 2019 11:33 am

Re: Using Python Wrapper

Post by tsassonx » Wed Mar 04, 2020 11:18 am

Hi,
There is still a problem with setup.py, and I don't know who to address this issue as there is no "Issues" tab on the github page.

The issue is that ctypes.WinDLL returns an exception in setup.py, even if the file ps2000.dll exists where it is being looked for, so if I comment out the whole section trying to locate the dll file, the package is installed and I can use it.

Here is the modified setup.py I was using, on two separate Windows 10 machines:

Code: Select all

#
# Copyright (C) 2017-2018 Pico Technology Ltd.
#
from __future__ import print_function
from distutils.core import setup

import ctypes
from ctypes import *
from ctypes.util import find_library
import sys
import os.path


# signalfile = ".sdkwarning"
# if not os.path.exists(signalfile):
#     name = 'ps2000'
#     try:
#         if sys.platform == 'win32':
#             result = ctypes.WinDLL(find_library(name))
#         else:
#             result = cdll.LoadLibrary(find_library(name))
#     except OSError:
#         print("Please install the PicoSDK in order to use this wrapper."
#               "Visit https://www.picotech.com/downloads")
#         exit(1)
#     open(signalfile, 'a').close()


setup(name='PicoSDK',
      version='1.0',
      description='PicoSDK Python wrapper',
      author='Pico Technology Ltd',
      author_email='support@picotech.com',
      url='https://www.picotech.com',
      packages=['picosdk'])


Post Reply