I have downloaded pyocd and built it successfully. Now I am able to run the tool from command line from any location. However when try to run it using pexpect it shows following error:
Traceback (most recent call last):
File "c:\Users\elephant\AppData\Local\Programs\Python\Python37-32\Scripts\pyocd-script.py", line 6, in <module>
from pkg_resources import load_entry_point
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 668, in _load_unlocked
File "<frozen importlib._bootstrap>", line 638, in _load_backward_compatible
File "C:\Projects\runner\mytest\venv\lib\site-packages\setuptools-39.1.0-py3.7.egg\pkg_resources\__init__.py", line 3086, in <module>
File "C:\Projects\runner\mytest\venv\lib\site-packages\setuptools-39.1.0-py3.7.egg\pkg_resources\__init__.py", line 3070, in _call_aside
File "C:\Projects\runner\mytest\venv\lib\site-packages\setuptools-39.1.0-py3.7.egg\pkg_resources\__init__.py", line 3099, in _initialize_master_working_set
File "C:\Projects\runner\mytest\venv\lib\site-packages\setuptools-39.1.0-py3.7.egg\pkg_resources\__init__.py", line 574, in _build_master
File "C:\Projects\runner\mytest\venv\lib\site-packages\setuptools-39.1.0-py3.7.egg\pkg_resources\__init__.py", line 892, in require
File "C:\Projects\runner\mytest\venv\lib\site-packages\setuptools-39.1.0-py3.7.egg\pkg_resources\__init__.py", line 778, in resolve
pkg_resources.DistributionNotFound: The 'pyocd==0.14.1.dev277+dirty' distribution was not found and is required by the application
Please help to understand what is wrong and why it works from command line?
The problem was that I tried to spawn pyocd.exe and pexpect was not able to find the package.
I changed the line to python -m pyocd and it just works fine.
I am new in Python and mistakenly thought that exe is compiled code as the other exe files in Windows. However, it is just an instruction to run the package using Python.
Related
I'm using the library Django-eel,which is a library i use alongside Django. After using pyinstaller to create a EXE file, the following error pops up when opening the EXE:
daphne\server.py:11: UserWarning: Something has already installed a non-asyncio Twisted reactor. Attempting to uninstall it; you can fix this warning by importing daphne.server early in your codebase or finding the package that imports Twisted and importing it later on.
Traceback (most recent call last):
File "manage.py", line 15, in <module>
File "django\core\management\__init__.py", line 419, in execute_from_command_line
utility.execute()
File "django\core\management\__init__.py", line 395, in execute
django.setup()
File "django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "django\apps\config.py", line 224, in create
import_module(entry)
File "importlib\__init__.py", line 127, in import_module
File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
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 "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "django_eel\__init__.py", line 11, in <module>
File "pkg_resources\__init__.py", line 1130, in resource_filename
File "pkg_resources\__init__.py", line 342, in get_provider
File "pkg_resources\__init__.py", line 886, in require
File "pkg_resources\__init__.py", line 772, in resolve
pkg_resources.DistributionNotFound: The 'django-eel' distribution was not found and is required by the application
[17688] Failed to execute script 'manage' due to unhandled exception!
So I tried using hidden-imports and add django-eel but that didn't work as well.
Any ideas?
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')]
I'm using python 3.7 and I want to create an executable from a script that use "cairosvg" package, the exe gives me this error while trying to run it:
Traceback (most recent call last):
File "testCairo.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
File "cairosvg\__init__.py", line 22, in <module>
File "pathlib.py", line 1199, in read_text
File "pathlib.py", line 1186, in open
File "pathlib.py", line 1039, in _opener
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\moham\\AppData\\Local\\Temp\\_MEI135122\\cairosvg\\VERSION'
[16072] Failed to execute script testCairo
any one has an idea how to solve this error ?
my code is only import cairosvg as the following:
import cairosvg
print('test')
Did you try to include the cairosvg folder in the pyinstaller command?
Pyinstaller --add-binary <path to cairosvg>;cairosvg testCairo.py
The package should be in your python installation folder, something like: "C:\Users<User>\AppData\Local\Programs\Python\Python37\Lib\site-packages\cairosvg".
The command should copy the cairosvg package folder from its location into your exe's dist folder. If you prefer one single file, you could also add "--onefile" to the pyinstaller command.
I'm trying to create a flatpak for our tool: https://github.com/IENT/RDPlot
My flatpak config and other files are here: https://github.com/IENT/flathub/tree/de.ient.RDPlot
When I try to call start the tool I get
flatpak-builder --run buildDir de.ient.RDPlot.yaml rdplot --filesystem=host
Traceback (most recent call last):
File "/app/bin/rdplot", line 5, in <module>
from pkg_resources import load_entry_point
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "/usr/lib/python3.5/site-packages/setuptools-22.0.5-py3.5.egg/pkg_resources/__init__.py", line 2927, in <module>
File "/usr/lib/python3.5/site-packages/setuptools-22.0.5-py3.5.egg/pkg_resources/__init__.py", line 2913, in _call_aside
File "/usr/lib/python3.5/site-packages/setuptools-22.0.5-py3.5.egg/pkg_resources/__init__.py", line 2940, in _initialize_master_working_set
File "/usr/lib/python3.5/site-packages/setuptools-22.0.5-py3.5.egg/pkg_resources/__init__.py", line 635, in _build_master
File "/usr/lib/python3.5/site-packages/setuptools-22.0.5-py3.5.egg/pkg_resources/__init__.py", line 943, in require
File "/usr/lib/python3.5/site-packages/setuptools-22.0.5-py3.5.egg/pkg_resources/__init__.py", line 829, in resolve
pkg_resources.DistributionNotFound: The 'sip' distribution was not found and is required by rdplot
I tried to set PYTHONPATH both locally before calling the command and in the flatpak config, but this did not work.
I verified that the package was installed correctly:
cd /var/lib/flatpak/app/de.ient.RDPlot/current/active/files/lib/python3.5/site-packages
ipython
In [1]: import sip
In [2]: sip.__file__
Out[2]: '/var/lib/flatpak/app/de.ient.RDPlot/x86_64/master/028d157308e77fd7ea66c39d93bf661dc3ddebc570aae0bcad6f07ab92ae4257/files/lib/python3.5/site-packages/sip.so'
Any advice on how to proceed would be great! I noticed that other flatpaks, for example (https://github.com/flathub/org.kde.krita) patch sip, but they use a different sip/pyqt version and I don't really think its the same problem. I think it simply is not found.
I created a python executable by using pyinstaller, but the jira module imported to my .py script is not present when I execute executable
Traceback (most recent call last):
File "myfile.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "c:\users\rajivkum\appdata\local\continuum\anaconda3\lib\site-packages\Py
Installer\loader\pyimod03_importers.py", line 389, in load_module
exec(bytecode, module.__dict__)
File "site-packages\jira\__init__.py", line 6, in <module>
File "site-packages\setuptools-18.5-py3.5.egg\pkg_resources\__init__.py", line
558, in get_distribution
File "site-packages\setuptools-18.5-py3.5.egg\pkg_resources\__init__.py", line
438, in get_provider
File "site-packages\setuptools-18.5-py3.5.egg\pkg_resources\__init__.py", line
959, in require
File "site-packages\setuptools-18.5-py3.5.egg\pkg_resources\__init__.py", line
846, in resolve
pkg_resources.DistributionNotFound: The 'jira' distribution was not found and is
required by the application
PyInstaller (and also cx_Freeze and Py2exe) have problems with including jira. What you have to do is to create, preferably in the same directory as your project a "hook file" for PyInstaller. Name the file
"hook-jira.py". Content of the file should look like that:
from PyInstaller.utils.hooks import copy_metadata
datas = copy_metadata('jira')
This will assure that PyInstaller will include jira. Then, you just have to run in the directory where myfile.py and hook file are located:
PyInstaller myfile.py --additional-hooks-dir=.
to tell PyInstaller that it should look for hook files in the current directory. This should solve the problem.