python TC-08 environment setup on mac M1

Come here to introduce yourself, who you are, and what you do
Post Reply
eklektek
User
User
Posts: 2
Joined: Wed Sep 21, 2022 3:56 pm

python TC-08 environment setup on mac M1

Post by eklektek »

As part of the PicoTech DevOps continuous integration is there a maintained page on the installation process for the PicoSDK.

Having installed PicoSDK 10.7.26 and then pulled the picosdk-python-wrappers from GitHub and stepped through the setup steps I get the issue mention in multiple other posts relating to the setting up of LD_LIBRARY_PATH

This appears to be a common issue? the tc08 library is visible here:
/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08 however setting LD_LIBRARY_PATH to this value yields the same issue. Please advise.

>>> from picosdk.usbtc08 import usbtc08
Traceback (most recent call last):
File "", line 1, in
File "/Users/user/projects/eklektek/python/github/clones/picotech/picosdk-python-wrappers/picosdk/usbtc08.py", line 19, in
usbtc08 = usbtc08lib()
File "/Users/user/projects/eklektek/python/github/clones/picotech/picosdk-python-wrappers/picosdk/usbtc08.py", line 16, in __init__
super(usbtc08lib, self).__init__("usbtc08")
File "/Users/user/projects/eklektek/python/github/clones/picotech/picosdk-python-wrappers/picosdk/library.py", line 49, in __init__
self._clib = self._load()
File "/Users/user/projects/eklektek/python/github/clones/picotech/picosdk-python-wrappers/picosdk/library.py", line 71, in _load
raise CannotFindPicoSDKError("PicoSDK (%s) not found, check %s" % (self.name, env_var_name))
picosdk.errors.CannotFindPicoSDKError: PicoSDK (usbtc08) not found, check LD_LIBRARY_PATH

AndrewA
PICO STAFF
PICO STAFF
Posts: 420
Joined: Tue Oct 21, 2014 3:07 pm

Re: python TC-08 environment setup on mac M1

Post by AndrewA »

Hi, Try-

Code: Select all

PYTHONPATH=/Library/Frameworks/PicoSDK.framework/Libraries LD_LIBRARY_PATH=/Library/Frameworks/PicoSDK.framework/Libraries python3 /Users/user/projects/eklektek/python/github/clones/picotech/picosdk-python-wrappers/picosdk/usbtc08.py
Regards Andrew
Technical Specialist

eklektek
User
User
Posts: 2
Joined: Wed Sep 21, 2022 3:56 pm

Re: python TC-08 environment setup on mac M1

Post by eklektek »

Hi Andrew, many thanks for the response.

I think I’ve implemented your suggestion. Please check; setting both variables & checking them, then importing usbtc08. Please see the code block starting beneath "Many thanks"

As can be seen I’m getting the compiled library, system architecture mis-match error

Code: Select all

(have 'x86_64', need 'arm64e' or 'arm64’)).
Suggesting that Rosetta isn’t kicking in?

You’ll notice that

Code: Select all

libusbtc08.2.dylib
is searched for on several occasions it is eventually found in

Code: Select all

'/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/'
However it is then determined that

Code: Select all

libusbtc08.2.dylib
is compiled to the wrong architecture.

Is there something that I need to do to force Rosetta to perform the translation?
This M1 machine is running Somoma 14.5 - perhaps Apple have done something that forces the user to make a conscious decision to use Rosetta?

However from the research I have done, I have been led to believe that Rosetta only supports application code, not library code and this example appears to confirm this.

Am I stuck on this M1 Mac until you guys compile for ARM64?

Many thanks

Code: Select all

(tc08-3919) username@MacPunch-2 picosdk-python-wrappers % export PYTHONPATH=/Library/Frameworks/PicoSDK.framework/Libraries     
(tc08-3919) username@MacPunch-2 picosdk-python-wrappers % export LD_LIBRARY_PATH=/Library/Frameworks/PicoSDK.framework/Libraries
(tc08-3919) username@MacPunch-2 picosdk-python-wrappers % echo $PYTHONPATH                                                     
/Library/Frameworks/PicoSDK.framework/Libraries
(tc08-3919) username@MacPunch-2 picosdk-python-wrappers % echo $LD_LIBRARY_PATH
/Library/Frameworks/PicoSDK.framework/Libraries
(tc08-3919) username@MacPunch-2 picosdk-python-wrappers % python 
Python 3.9.19 (main, May  6 2024, 14:39:30) 
[Clang 14.0.6 ] :: Anaconda, Inc. on darwin
Type "help", "copyright", "credits" or "license" for more information.

>>> from picosdk.usbtc08 import usbtc08 as tc08 

Code: Select all

Traceback (most recent call last):
  File "/Users/username/projects/eklektek/python/github/clones/picotech-1/picosdk-python-wrappers/picosdk/library.py", line 85, in _load
    result = cdll.LoadLibrary(library_path)
  File "/opt/anaconda3/envs/tc08-3919/lib/python3.9/ctypes/__init__.py", line 460, in LoadLibrary
    return self._dlltype(name)
  File "/opt/anaconda3/envs/tc08-3919/lib/python3.9/ctypes/__init__.py", line 382, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.dylib, 0x0006): tried: '/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/libusbtc08.dylib' (no such file), '/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.dylib' (no such file), '/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.2.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/libusbtc08.2.dylib' (no such file), '/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.2.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.2.dylib' (no such file), '/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.2.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
During handling of the above exception, another exception occurred:

Code: Select all

Traceback (most recent call last):
  File "", line 1, in 
  File "/Users/username/projects/eklektek/python/github/clones/picotech-1/picosdk-python-wrappers/picosdk/usbtc08.py", line 19, in 
    usbtc08 = usbtc08lib()
  File "/Users/username/projects/eklektek/python/github/clones/picotech-1/picosdk-python-wrappers/picosdk/usbtc08.py", line 16, in __init__
    super(usbtc08lib, self).__init__("usbtc08")
  File "/Users/username/projects/eklektek/python/github/clones/picotech-1/picosdk-python-wrappers/picosdk/library.py", line 49, in __init__
    self._clib = self._load()
  File "/Users/username/projects/eklektek/python/github/clones/picotech-1/picosdk-python-wrappers/picosdk/library.py", line 87, in _load
    raise CannotOpenPicoSDKError("PicoSDK (%s) not compatible (check 32 vs 64-bit): %s" % (self.name, e))
picosdk.errors.CannotOpenPicoSDKError: PicoSDK (usbtc08) not compatible (check 32 vs 64-bit): dlopen(/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.dylib, 0x0006): tried: '/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/libusbtc08.dylib' (no such file), '/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.dylib' (no such file), '/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.2.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/libusbtc08.2.dylib' (no such file), '/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.2.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.2.dylib' (no such file), '/Library/Frameworks/PicoSDK.framework/Libraries/libusbtc08/libusbtc08.2.dylib' (mach-o file, but is an incompatible architecture (have 'x86_64', need 'arm64e' or 'arm64'))
>>>

Post Reply