pyinstaller exe file don't work with pyaudio - speech recognition - pyinstaller

Hi i am a intermediate python developer and I made a voice paint app that you can control app with voice , for this app i used speech recognition for my app and speech recognition needs pyaudio .
for installing pyaudio i couldn't use pip or pipwin and i installed it using .whl file downloaded from internet and it works!
now in my app when I run it in python ide or vs code it works but when i use pyinstaller to get exe it gives error ( no module named pyaudio )
i tried lots of ways but none worked.
can anybody help?

Question, when you say "i tried lots of ways but none worked"; did this include adding pyaudio to a pyinstaller hook?
from PyInstaller.utils.hooks import collect_data_files,collect_submodules
#should only require hiddenimports
#datas = collect_data_files('pyaudio')
hiddenimports = collect_submodules('pyaudio')

Related

PackageNotFoundError: bokeh after compiling with pyinstaller

I have a python project that imports bokeh, and I use pip install bokeh to install bokeh 3.0.3 version, and everything works fine. However, after I compile this project using pyinstaller, the executable file crashes at launch with the following error:
importlib.metadata.PackageNotFoundError: bokeh
Also the way I'm importing bokeh functionalities into my project is like this:
from bokeh.io import output_file, show
I have searched around, but haven't been able to find any useful clue on how to solve this issue. I would appreciate any help on this.
Python versoin 3.8.13
Pyinstaller version: 5.7.0
I have also tried using conda to install bokeh, but it does not make any difference.
You may find this issue useful for your case.
https://github.com/pyinstaller/pyinstaller/discussions/6033
In your case there is the need to include the "--copy-metadata bokeh" command when you are running pyInstaller or use the copy_metadata() function in your spec file.
For more details refer to the github issue as it goes a little more in detail.

RobotFramework RIDE cannot import library

I have a file right here: Library ../../MyLib/My_Lib.py, and I try to import the python file in RIDE, but RIDE still report "FAIL : No keyword with name '****' found", and this keyword is defined in the My_Lib.py, seems RIDE cannot find the python file.
I using python 2.7.8+Robot Framework 3.1.2+windows server 2012r2. I even selected Library -> Name -> Browse in RIDE, but the error still there and this whole robot test case folder is copied from another server which is working fine
Can anyone suggest what have I missed?
Ah! I have worked this out, if anyone else meets the same issue, you can click Tools->view RIDE Log, to see what's happening there. For my case, it's because I didn't install thrift but the My_Lib.py obviously used thrift module, so the My_Lib.py compile failed with "No module named thrift.Thrift".
Is it possible the Python library was created to work with Python 3.x.x leading it to not work on your Python 2.7.8? See https://wiki.python.org/moin/Python2orPython3
Check what python version is being run on the other server where the test is running fine. You might need to update your local Python version.
Also, you could try running the Robot test outside of RIDE just in case. You may do so by navigating to the test folder where the .robot file resides and running the following command:
robot test_file_name.robot
See if you get the same error that way. Please report back after doing the mentioned checks and we can continue debugging, my reputation doesn't let me comment on your question so I will just update the answer as we go along.

PyQt5 translation: is it possible to run pylupdate5 from Python?

I have some PyQt5 application with some tr() translations in it. I have a Python script that compiles UI forms and resources, and I want it to also update the ts file with translations, because it's a bit annoying to run pylupdate manually each time.
Alas, I haven't find any information, how to run the Python functions that provide translation file compilation in PyQt5. Haven't you ever got the same problem?
I was able to do it like this
import os
ret = os.system("E:\Anaconda3\Library\\bin\\pylupdate5.exe -verbose Main.py otherfile.py thirdfile.py -ts zh_CN.ts")
Hopefully you found it as well

Let atom editor recognize external APIs

I'm trying to set up a python like environment with Atom-editor on a Linux machine.
I find the autocomplete-python package that uses jedi.
In the settings of the package I tried to add some python path where the APIs are (/usr/lib/python2.7/dist-packages/) but then the autocompletion doesn't recognize these libraries (for example the PyQt ones)
Am I missing something?
For anybody having the same issue please look here.
Basically everything should work out of the box, but if it does not -- try to configure path to python executable with which you have installed your external module. If it's still fails to complete -- try to configure extra path to python modules. (usually your site-packages directory)

To set current working directory in PyDev interactive console

I know that when I start the interactive console in pydev using ctrl + alt + enter, the working directory is not the one the project is in. Therefore, I adopted this code when the console starts (which worked):
import sys; print('%s %s' % (sys.executable or sys.platform, sys.version))
import os
cwd_path = [path for path in sys.path if 'org.python.pydev' not in path and 'Python3' not in path and 'python33.zip' not in path]
if len(cwd_path) == 1:
os.chdir(cwd_path[0])
However, the problem is it only takes me to the folder of the project, instead of the file. For example, my file is in src//com/main//test//Test.py , and this code will only take me to the folder where src is in. Is there anyway to get around this?
Thanks!
-Shawn
This is not technically a work-around, but I do find that Spyder IDE solves this problem pretty well. I just installed from the WinPython package, and it worked very well for me.
The link to WinPython
I'll still really appreciate it if someone can provide a way to fix it in Eclipse/Pydev - because that's been what I use for all other projects and I really like it. Thanks!

Resources