-
Notifications
You must be signed in to change notification settings - Fork 496
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Session open error using pyinstaller #1529
Comments
The problem is related to package entry points used by pyocd for plugins. Another user (Giovanni I.) has the solution below. Please note that I haven't tested this out myself. And Linux/Mac may be slightly different than Windows. At some point I'd like to build and release a standard binary for pyocd, but it will take some time and isn't particularly high priority (this would be a great contribution from someone!). From Giovanni:
|
Hi, Thanks for your answer. I did what you told me:
I now have a different issue. When I run the executable generated by PyInstaller on Linux, I get the following error:
The distribution not found is different everytime I run the executable. It misses Here is my new spec file: # -*- mode: python ; coding: utf-8 -*-
import platform
from PyInstaller.utils.hooks import get_package_paths, collect_entry_point, copy_metadata, collect_all
datas_probe, hiddenimports_probe = collect_entry_point('pyocd.probe')
datas_rtos, hiddenimports_rtos = collect_entry_point('pyocd.rtos')
block_cipher = None
is_windows = (platform.system() == "Windows")
cpm_path = get_package_paths('cmsis_pack_manager')[1]
if is_windows:
# cpm_lib_name = "native.so"
# cpm_lib_path = os.path.join(cpm_path, 'cmsis_pack_manager', cpm_lib_name)
cpm_lib_path = cpm_path
cpm_lib_path_deploy = 'cmsis_pack_manager/cmsis_pack_manager'
else:
# cpm_lib_name = "_native__lib.so"
# cpm_lib_path = os.path.join(cpm_path, cpm_lib_name)
cpm_lib_path = cpm_path
cpm_lib_path_deploy = 'cmsis_pack_manager'
pyocd_path = get_package_paths('pyocd')[1]
svd_path = os.path.join(pyocd_path, 'debug', 'svd', 'svd_data.zip')
datas = [
('../img', 'img'),
('../ui', 'ui'),
('../src', 'src'),
('../binaries', 'binaries'),
('../patchs', 'patchs'),
(cpm_lib_path, cpm_lib_path_deploy),
(svd_path, 'pyocd/debug/svd/.')
]
datas = datas + datas_probe + datas_rtos
hiddenimports = hiddenimports_probe + hiddenimports_rtos
a = Analysis(
['../programmer.py'],
pathex=[],
binaries=[],
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='programmer',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='programmer',
) Maybe I did not understand something in your instructions but the problem appears when I add the |
Well, I was just passing along instructions from another user, so I can't really tell you what's wrong, unfortunately. However, it sounds more like a general pyInstaller usage issue rather than something specific to pyocd—just a guess, though. However, it turns out that the changes to cmsis-pack-manager are unnecessary unless you are intending to package CMSIS-Packs directly in the pyocd executable. (I'll update the instructions from earlier to remove this.) |
Hi @Villanut0, |
I think I got this working for my application (tm_fct). I am just including pyocd as a module so maybe it is different but using this specfile it does seem to be working. The main problem was that things were just not getting copied so I had to add them explicitly.
|
Hi @edcloudcycle! |
Hi,
I think you will need the _internal directory as well as the exe. If you want everything inside the exe I think there is an option for that.
Cheers
Ed
From: Julián Ordóñez ***@***.***>
Sent: Monday, January 8, 2024 2:48 AM
To: pyocd/pyOCD ***@***.***>
Cc: Ed Waugh ***@***.***>; Mention ***@***.***>
Subject: Re: [pyocd/pyOCD] Session open error using pyinstaller (Issue #1529)
Hi @edcloudcycle <https://github.com/edcloudcycle>
I wanted to thank you for providing the .spec file, it worked fine, I just had to remove the line datas += copy_metadata('nidaqmx') since I didn't need it.
The command I used was pyinstaller file.spec, this generated the .exe and the _internal directory, but if I move the .exe to another location it does not work.
Is it related to this comment ?
# Custom spec file for pyinstaller DO NOT CALL pyinstaller DIRECTLY
# Instead use the package_to_exe.py script provided which will also copy all other files needed
I couldn't find the package_to_exe.py file.
Any suggestion?
—
Reply to this email directly, view it on GitHub <#1529 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/AQOYBKG44WYLRFJT2ZWPR2TYNNM7TAVCNFSM6AAAAAAWUJRCX2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBQGMYTMOBUHE> .
You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Hi all! Somehow I deleted my previous comment 😅 I was able to generate an executable that runs but when i try to open the session with: I get this error:
This is the .spec I use to generate the exe: from PyInstaller.utils.hooks import get_package_paths, collect_entry_point, copy_metadata, collect_all
datas_probe, hiddenimports_probe = collect_entry_point('pyocd.probe')
datas_rtos, hiddenimports_rtos = collect_entry_point('pyocd.rtos')
pyocd_path = get_package_paths('pyocd')[1]
cmsis_path = "..\\.\\venv\\Lib\\site-packages\\cmsis_pack_manager"
pylink_path = get_package_paths('pylink')[1]
datas = [(pyocd_path, 'pyocd/.'),
(cmsis_path, 'cmsis_pack_manager/.'),
(pylink_path, 'pylink/.')]
datas = datas + datas_probe + datas_rtos + datas_targets
hiddenimports = hiddenimports_probe + hiddenimports_rtos
a = Analysis(
['controller.py'],
pathex=[],
binaries=[],
datas=datas,
hiddenimports=hiddenimports,
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='controller',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
) Do you know how I can include the target types installed in my environment? |
Hi Julian, |
Yes, when it is not packaged it works perfectly. |
Unfortunately it didn't work. I found that the managed packages I installed are stored in my I managed to copy these files to the package but pyocd was not using it as I was getting the same error. Then I tried adding the pack session option with the path to the
Can you think of anything else I could try? Thanks |
Maybe if you try activating your venv before installing pyocd and the packs they will all be in the right place. That might help. You could also try copying any missing files manually to the folders after they are created. |
This worked for me to generate a single .exe for my application, which is a flash loader (thanks to the help from the posts in this thread). I run this with pyinstaller my_flashdaq.spec:
|
I have some updates too, I finally got it working. I was having this error triying to open the session in the .exe: So I copied the missing pack files (from the image of my previous comment) into my project and then when I opened the session I added the option keil_path = [os.path.join(managed_packs_path, 'Keil.STM32L4xx_DFP.2.6.2.pack'), os.path.join(managed_packs_path, 'Keil.STM32F4xx_DFP.2.17.1.pack')]
session = ConnectHelper.session_with_chosen_probe(blocking=False, options={"chip_erase": "sector", "target_override": target_str, "pack": keil_path})
session.open() I hope this helps someone :) |
Hi !
I'm trying to create an executable for my python application with Pyinstaller but I'm running into some issues.
My application is flashing STM32L475 MCUs by using 2 STLinksV3 and is working fine before using Pyinstaller.
First, I had the same problems as #1422 and #1358 but I was able to resolve them thanks to the discussion #1274. I added the following lines :
And I'm now able to get the sessions for my STLinks using
ConnectHelper.get_sessions_for_all_connected_probes()
The problem now, is that when I try to open these sessions my application crashes with the following output:
My .spec file is the following:
I don't know if I'm doing something wrong. The same application is working fine until I try to pack it with Pyinstaller.
Do you have an idea of what's happening?
Thanks
The text was updated successfully, but these errors were encountered: