Open gamer388 opened 3 years ago
Have a look at this issue (https://github.com/pyvisa/pyvisa-py/issues/216), which describes your issue and its solution (basically adding pyvisa_py to the list of hidden files). I never used PyInstaller myself and offered to people using it to make a PR to clarify the situation but it never happened. You are welcome to make a PR to update the docs if you feel so inclined.
Ok I'll try this when building the executable with pyinstaller when I come back at home this evening. But I already tried to do add pyvisa and pyvisa-py but maybe the typo wasn't exactly correct.
Edit: I already saw that issue #216 but didn't manage to get it working. Seriously I think the name of the package is somewhat wrong because this error shouldn't even happen if I installed correctly the package I'm trying to use.
Note that the installed python package is pyvisa_py
while the name of the project on PyPI is pyvisa-py
(this follows the same convention used for example by pytest extensions).
I just posted this in #216, but in case you are still working on it, you need to add "pyvisa_py" as a hidden import. The reason it's a "hidden" import is that pyvisa does not import it directly, but does some fancy dynamic importing at runtime.
You can do this either with the "hidden-import" command line option:
pyinstaller --hidden-import=pyvisa_py example.py
Or (my preferred way), by modifying your .spec file:
block_cipher = None
a = Analysis(['minimal.py'],
pathex=['/Developer/PItests/minimal'],
binaries=None,
datas=None,
hiddenimports=['pyvisa_py'], # <----- this is the key line
hookspath=None,
runtime_hooks=None,
excludes=None,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,... )
coll = COLLECT(...)
I faced the same issue -- The solution jaydoherty recommends fixed it.
I just posted this in #216, but in case you are still working on it, you need to add "pyvisa_py" as a hidden import. The reason it's a "hidden" import is that pyvisa does not import it directly, but does some fancy dynamic importing at runtime.
You can do this either with the "hidden-import" command line option:
pyinstaller --hidden-import=pyvisa_py example.py
Or (my preferred way), by modifying your .spec file:
block_cipher = None a = Analysis(['minimal.py'], pathex=['/Developer/PItests/minimal'], binaries=None, datas=None, hiddenimports=['pyvisa_py'], # <----- this is the key line hookspath=None, runtime_hooks=None, excludes=None, cipher=block_cipher) pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher) exe = EXE(pyz,... ) coll = COLLECT(...)
I'm trying to build an executable from a simple python script using pyvisa-py but I'm running into error after I run the executable generated by pyinstaller.
Here what my small python code looks like
During handling of the above exception, another exception occurred:
Also I installed pyvisa and pyvisa-py using pycharm package installer builtin function (work the same as pip3)
If I do list pip3 I got
I have experience using pyinstaller with other python code I have written in the past but I'm a beginner with pyvisa. I spent my whole last night trying to figure out what was the problem but I coudn't so that's why I'm asking here for help. Sorry if the same question have been posted before I searched everywhere a solution but didn't find any. https://stackoverflow.com/questions/67168199/error-when-running-executable-generated-by-pyinstaller-pyvisa-py?noredirect=1#comment118755247_67168199 I also posted my questions about the problem on stackoverflow but got no useful answer there so I hope to get help here.