Compile file with vosk api with PyInstaller - python

I try to compile exe file from the python file with vosk library.
Compilation is ok.
Everytime when I try to run exe obtain this error:
Traceback (most recent call last):
File "Vega.py", line 10, in <module>
from vosk import Model, KaldiRecognizer
File "C:\Users\Alexandr\AppData\Local\Temp\embedded.zm51h3af.zip\shibokensupport\__feature__.py", line 142, in _import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 540, in exec_module
File "vosk\__init__.py", line 21, in <module>
File "vosk\__init__.py", line 12, in open_dll
File "os.py", line 1111, in add_dll_directory
FileNotFoundError: [WinError 2] The specified file cannot be found: 'C:\\Users\\Alexandr\\AppData\\Local\\Temp\\_MEI126762\\vosk'
[920] Failed to execute script Vega
What should I do?

Solved
You need to create .spec file and write here something like that datas=[('D:\\Python39\\Lib\\site-packages\\vosk', './vosk')]

Related

OSError: /usr/lib/libyara.so: cannot open shared object file: No such file or directory

I have some issue trying to run Volatility 3 Framework.
git clone https://github.com/volatilityfoundation/volatility3.git
cd volatility3/
python3 vol.py ../ramdumps/1289.raw windows.pslist.PsList
I got this error traceback:
Volatility 3 Framework 2.0.0
Failed to import '/usr/lib/libyara.so'
PATH = /home/user/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/home/user/go/bin;/usr/lib
Traceback (most recent call last):
File "vol.py", line 10, in <module>
volatility3.cli.main()
File "/home/user/Documents/volatility3/volatility3/cli/__init__.py", line 625, in main
CommandLine().run()
File "/home/user/Documents/volatility3/volatility3/cli/__init__.py", line 229, in run
True) # Will not log as console's default level is WARNING
File "/home/user/Documents/volatility3/volatility3/framework/__init__.py", line 127, in import_files
ignore_errors)
File "/home/user/Documents/volatility3/volatility3/framework/__init__.py", line 152, in import_file
importlib.import_module(module)
File "/usr/lib/python3.6/importlib/__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/home/user/Documents/volatility3/volatility3/framework/plugins/yarascan.py", line 17, in <module>
import yara
File "/home/user/.local/lib/python3.6/site-packages/yara/__init__.py", line 7, in <module>
from yara.rules import compile
File "/home/user/.local/lib/python3.6/site-packages/yara/rules.py", line 17, in <module>
from yara.libyara_wrapper import *
File "/home/user/.local/lib/python3.6/site-packages/yara/libyara_wrapper.py", line 315, in <module>
libyaradll = cdll.LoadLibrary(library)
File "/usr/lib/python3.6/ctypes/__init__.py", line 426, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python3.6/ctypes/__init__.py", line 348, in __init__
self._handle = _dlopen(self._name, mode)
OSError: /usr/lib/libyara.so: cannot open shared object file: No such file or directory
Someone already had the same error a few years ago but none of the answers worked for me.
I'm using python 3.6.9 and Xubuntu 18.04.6
You have to uninstall yara with pip. Only tara-python must be installed.
Did you install the requirements with
pip3 install -r requirements.txt
?

I cant run py python kivy app after i build the exe file

I tested my app in vs code and ran my app fine . but when I export this app :
Traceback (most recent call last):
File "main.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 546, in exec_module
File "kivy\__init__.py", line 272, in <module>
File "C:\Users\0123m\AppData\Local\Programs\Python\Python39\Lib\site-packages\PyInstaller\hooks\rthooks\pyi_rth_pkgutil.py", line 71, in _pyi_pkgutil_iter_modules
assert pkg_path.startswith(SYS_PREFIX)
TypeError: startswith first arg must be str or a tuple of str, not PureWindowsPath
I exported this using the command that kivy provided

How to execute django commands from another django project?

I have two django project on the same server.
Project 1 : is running (with gunicorn) to receive rest request and display data.
Project 2: is used only to execute django commands and is not running.
I would like to run a command from project2 inside project1 but when i do nothing is happening.
I tried :
Popen(["/opt/xxx/venv3/bin/python", "/opt/xxx/src/manage.py", "custom_commands", "params"])
os.system("/opt/xxx/venv3/bin/python /opt/xxx/src/manage.py custom_commands params")
without success (i tried to read the ouput of Popen but it's empty).
When i run the same command inside a python shell on the server it works so its must be related to calling a django command from another django project.
----Edit----
I managed to read the stderr with popen and i get :
Traceback (most recent call last):\n File "/opt/project2/venv3/lib/python3.9/site-packages/django/core/management/__init__.py", line 224, in fetch_command\n app_name = commands[subcommand]\nKeyError: \'mail_lre\'\n\nDuring handling of the above exception, another exception occurred:\n\nTraceback (most recent call last):\n File "/opt/project2/src/manage.py", line 22, in <module>\n main()\n File "/opt/project2/src/manage.py", line 18, in main\n execute_from_command_line(sys.argv)\n File "/opt/project2/venv3/lib/python3.9/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line\n utility.execute()\n File "/opt/project2/venv3/lib/python3.9/site-packages/django/core/management/__init__.py", line 395, in execute\n self.fetch_command(subcommand).run_from_argv(self.argv)\n File "/opt/project2/venv3/lib/python3.9/site-packages/django/core/management/__init__.py", line 231, in fetch_command\n settings.INSTALLED_APPS\n File "/opt/project2/venv3/lib/python3.9/site-packages/django/conf/__init__.py", line 82, in __getattr__\n self._setup(name)\n File "/opt/project2/venv3/lib/python3.9/site-packages/django/conf/__init__.py", line 69, in _setup\n self._wrapped = Settings(settings_module)\n File "/opt/project2/venv3/lib/python3.9/site-packages/django/conf/__init__.py", line 170, in __init__\n mod = importlib.import_module(self.SETTINGS_MODULE)\n File "/usr/local/lib/python3.9/importlib/__init__.py", line 127, in import_module\n return _bootstrap._gcd_import(name[level:], package, level)\n File "<frozen importlib._bootstrap>", line 1030, in _gcd_import\n File "<frozen importlib._bootstrap>", line 1007, in _find_and_load\n File "<frozen importlib._bootstrap>", line 972, in _find_and_load_unlocked\n File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed\n File "<frozen importlib._bootstrap>", line 1030, in _gcd_import\n File "<frozen importlib._bootstrap>", line 1007, in _find_and_load\n File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked\n File "<frozen importlib._bootstrap>", line 680, in _load_unlocked\n File "<frozen importlib._bootstrap_external>", line 790, in exec_module\n File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed\n File "/opt/editik/src/Editik_django/__init__.py", line 4, in <module>\n from utils.apps import app_ready\n File "/opt/project2/src/utils/apps.py", line 15, in <module>\n from api.settings import LOG_EDITIK_DIR\n File "/opt/project2/src/api/__init__.py", line 4, in <module>\n from utils.apps import app_ready\nImportError: cannot import name \'app_ready\' from partially initialized module \'utils.apps\' (most likely due to a circular import) (/opt/project2/src/utils/apps.py)
Really weird since it's working outside django project.
Ok i solved it by adding --pythonpath and --settings at the end of my command.
Like :
Popen(["/opt/xxx/venv3/bin/python", "/opt/xxx/src/manage.py", "custom_commands", "params", "--pythonpath='/opt/xxx/src/'", "--settings='api.settings'"])
os.system("/opt/xxx/venv3/bin/python /opt/xxx/src/manage.py custom_commands params --pythonpath='/opt/xxx/src/' --settings='app.settings'")

Pyinstaller Matplotlib [Errno 2] No such file or directory: 'C:\\Users\\User\\AppData\\Local\\Temp\\_MEI142562\\matplotlib\\mpl-data\\matplotlibrc'

I want to make a standalone exe with pyinstaller.
If I execute the .exe file I get the following Error:
C:\Users\User\Desktop\invpepeshort>.\invpepe.exe
Traceback (most recent call last):
File "invpepe.py", line 14, in <module>
import matplotlib.pyplot as plt
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
File "matplotlib\__init__.py", line 820, in <module>
File "matplotlib\__init__.py", line 725, in _rc_params_in_file
File "contextlib.py", line 117, in __enter__
File "matplotlib\__init__.py", line 703, in _open_file_or_url
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\User\\AppData\\Local\\Temp\\_MEI142562\\matplotlib\\mpl-data\\matplotlibrc'
I hope someone can suggest a fix.
I don't know if it's the most correct answer, but I had the exact same problem as you.
For me solved, re-installing the Pyinstaller version develop
pip install https://github.com/pyinstaller/pyinstaller/archive/develop.zip

module 'parsedatetime.pdt_locales' has no attribute 'de_DE'

I tried to compile my python script into exe using pyinstaller. It came out successful. But when I try to run the exe file, it shows an error with parsedatetime module.
I'm using Python 3.8.3. Please help. Thank you very much.
Here is the error:
Traceback (most recent call last):
File "trendy.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "c:\python38\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "site-packages\parsedatetime\__init__.py", line 69, in <module>
File "site-packages\parsedatetime\__init__.py", line 69, in <listcomp>
File "site-packages\parsedatetime\pdt_locales\__init__.py", line 29, in load_locale
AttributeError: module 'parsedatetime.pdt_locales' has no attribute 'de_DE'

Categories

Resources