Python app build with flatpak can not find package - python

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.

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
?

Could not find Django-eel - pyinstaller+django-eel

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?

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

Error: 'dagster.core.types.runtime' is not a package

Installed dagster for the first time in a conda environment and tried to run the airline demo as described here. The following are the steps I followed.
conda env create -n dagster python=3.7
conda activate dagster
pip install dagster dagit
git clone git#github.com/dagster-io/dagster.git
cd dagster/examples
pip install -e '[.full]'
docker-compose up -d
cd dagster_examples/airline_demo
dagit
I then get the following stack trace ending in the 'dagster.core.types.runtime' is not a package message:
Loading repository...
Traceback (most recent call last):
File "/Users/timrozmajzl/miniconda3/envs/dagster/bin/dagit-cli", line 8, in <module>
sys.exit(main())
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/site-packages/dagit/cli.py", line 110, in main
cli = create_dagit_cli()
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/site-packages/dagit/cli.py", line 21, in create_dagit_cli
return ui(auto_envvar_prefix='DAGIT') # pylint: disable=no-value-for-parameter
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/site-packages/click/core.py", line 764, in __call__
return self.main(*args, **kwargs)
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/site-packages/click/core.py", line 717, in main
rv = self.invoke(ctx)
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/site-packages/click/core.py", line 956, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/site-packages/click/core.py", line 555, in invoke
return callback(*args, **kwargs)
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/site-packages/dagit/cli.py", line 72, in ui
host_dagit_ui(handle, host, port, storage_fallback, reload_trigger)
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/site-packages/dagit/cli.py", line 81, in host_dagit_ui
app = create_app(handle, instance, reloader)
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/site-packages/dagit/app.py", line 160, in create_app
version=__version__,
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/site-packages/dagster_graphql/implementation/context.py", line 17, in __init__
self.repository_definition = self.get_handle().build_repository_definition()
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/site-packages/dagster/core/definitions/handle.py", line 392, in build_repository_definition
obj = self.entrypoint.perform_load()
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/site-packages/dagster/core/definitions/handle.py", line 445, in entrypoint
return self.data.get_repository_entrypoint(from_handle=self)
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/site-packages/dagster/core/definitions/handle.py", line 522, in get_repository_entrypoint
return LoaderEntrypoint.from_yaml(self.repository_yaml, from_handle=from_handle)
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/site-packages/dagster/core/definitions/handle.py", line 175, in from_yaml
return LoaderEntrypoint.from_module_target(module_name, fn_name, from_handle)
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/site-packages/dagster/core/definitions/handle.py", line 161, in from_module_target
module = importlib.import_module(module_name)
File "/Users/timrozmajzl/miniconda3/envs/dagster/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
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 "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/timrozmajzl/Projects/dagster/dagster/examples/dagster_examples/airline_demo/repository.py", line 3, in <module>
from .pipelines import define_airline_demo_ingest_pipeline, define_airline_demo_warehouse_pipeline
File "/Users/timrozmajzl/Projects/dagster/dagster/examples/dagster_examples/airline_demo/pipelines.py", line 14, in <module>
from .resources import postgres_db_info_resource, redshift_db_info_resource
File "/Users/timrozmajzl/Projects/dagster/dagster/examples/dagster_examples/airline_demo/resources.py", line 3, in <module>
from .types import DbInfo
File "/Users/timrozmajzl/Projects/dagster/dagster/examples/dagster_examples/airline_demo/types.py", line 8, in <module>
from dagster.core.types.runtime.runtime_type import create_string_type
ModuleNotFoundError: No module named 'dagster.core.types.runtime.runtime_type'; 'dagster.core.types.runtime' is not a package
Thanks for reporting this issue! After some digging, it seems like this commit was not compatible with the latest release of dagster (at the time) which caused the error.
Re-running this workflow with the most recent dagster master and dependencies should resolve this. Opening an issue here to track a more long-term fix.
More details: In this commit, 'create_string_type' is introduced to both 'examples/dagster_examples/airline_demo/types.py' and 'python_modules/dagster/dagster/core/types/runtime/runtime_type.py'. However, based on the commands pasted in the question and present in the airline demo steps, airline_demo pipeline was running the tip of master (which contained 'create_string_type') with an older dagster package (from the latest release, which did not contain 'create_string_type').

Run installed package from pexpect

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.

Categories

Resources