how to install workbench Python dependencies for a flatpak build?
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
how to install workbench Python dependencies for a flatpak build?
Hi,
I just moved from Appimage to Flatpak to circumvent the keyboard issue in the latest weekly 0.21 builds. The flatpak requires reinstallation of the additional workbenches to its own space. For WBs with Python dependencies, how are these installed? FC doesn't seem to handle that internally, the addon manager doesn't display any dependencies (as opposed to the AppImage build), and the flatpak build doesn't seem to recognize the system python packages.
thanks
GG
I just moved from Appimage to Flatpak to circumvent the keyboard issue in the latest weekly 0.21 builds. The flatpak requires reinstallation of the additional workbenches to its own space. For WBs with Python dependencies, how are these installed? FC doesn't seem to handle that internally, the addon manager doesn't display any dependencies (as opposed to the AppImage build), and the flatpak build doesn't seem to recognize the system python packages.
thanks
GG
- adrianinsaval
- Veteran
- Posts: 5541
- Joined: Thu Apr 05, 2018 5:15 pm
Re: how to install workbench Python dependencies for a flatpak build?
in 0.21 the addon manager should offer you to install dependencies when you install the addons (provided that said addons have declared those dependencies correctly), please provide your full version info. Alternatively you can use pip inside the flatpak env with the command
Code: Select all
flatpak run --command=pip org.freecadweb.FreeCAD
Re: how to install workbench Python dependencies for a flatpak build?
Hi,
the version info is
As you can see, there are plenty of addons installed, but there are no listed dependencies. During startup FC mentions "No module named scipy" from A3, but I think in total >10 packages are missing .. which are difficult to figure out now. I tried the command you suggested, but I was not quite successful. "pip install scipy" as command doesn't work at all, the less obvious variant
seems to be "almost right". It downloaded and installed scipy (it claims "successfully"?!) but then throws an error:
On the next FC start the error regarding no scipy is still there. I had this issue in a slightly older flatpak, but not in the appimage versions.
Do you have another idea?
thanks
GG
the version info is
Code: Select all
OS: KDE Flatpak runtime (KDE//usr/share/xsessions/plasma5)
Word size of FreeCAD: 64-bit
Version: 0.21.0.31979 (Git)
Build type: Release
Branch: (HEAD detached at d13926baa8)
Hash: d13926baa856fd0466f0049bf5cc34c7f5c1e308
Python 3.10.6, Qt 5.15.8, Coin 4.0.0, Vtk 8.2.0, OCC 7.6.3
Locale: C/Default (C)
Installed mods:
* sheetmetal 0.2.61
* kicadStepUpMod 10.17.1
* Assembly4 0.12.6
* toSketch 1.0.1
* fasteners 0.4.55
* LCInterlocking
* Reinforcement
* A2plus 0.4.60k
* EM
* ThreadProfile 1.84.0
* Lithophane
* lattice2 1.0.0
* Assembly3 0.11.4
* InventorLoader 1.3.0
* FEMbyGEN 1.2.0
* freecad.gears 1.0.0
* Curves 0.6.8
* QuickMeasure 2022.10.28
* pyrate
* OpticsWorkbench 1.0.9
Code: Select all
flatpak run --command=pip org.freecadweb.FreeCAD install scipy
Code: Select all
Defaulting to user installation because normal site-packages is not writeable
Collecting scipy
Downloading scipy-1.10.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (34.4 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 34.4/34.4 MB 6.3 MB/s eta 0:00:00
Requirement already satisfied: numpy<1.27.0,>=1.19.5 in /app/lib/python3.10/site-packages (from scipy) (1.21.4)
Installing collected packages: scipy
Successfully installed scipy-1.10.1
--- Logging error ---
Traceback (most recent call last):
File "/app/lib/python3.10/site-packages/pip/_internal/utils/logging.py", line 177, in emit
self.console.print(renderable, overflow="ignore", crop=False, style=style)
File "/app/lib/python3.10/site-packages/pip/_vendor/rich/console.py", line 1673, in print
extend(render(renderable, render_options))
File "/app/lib/python3.10/site-packages/pip/_vendor/rich/console.py", line 1305, in render
for render_output in iter_render:
File "/app/lib/python3.10/site-packages/pip/_internal/utils/logging.py", line 134, in __rich_console__
for line in lines:
File "/app/lib/python3.10/site-packages/pip/_vendor/rich/segment.py", line 249, in split_lines
for segment in segments:
File "/app/lib/python3.10/site-packages/pip/_vendor/rich/console.py", line 1283, in render
renderable = rich_cast(renderable)
File "/app/lib/python3.10/site-packages/pip/_vendor/rich/protocol.py", line 36, in rich_cast
renderable = cast_method()
File "/app/lib/python3.10/site-packages/pip/_internal/self_outdated_check.py", line 130, in __rich__
pip_cmd = get_best_invocation_for_this_pip()
File "/app/lib/python3.10/site-packages/pip/_internal/utils/entrypoints.py", line 58, in get_best_invocation_for_this_pip
if found_executable and os.path.samefile(
File "/usr/lib/python3.10/genericpath.py", line 101, in samefile
s2 = os.stat(f2)
FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/pip'
Call stack:
File "/app/bin/pip", line 8, in <module>
sys.exit(main())
File "/app/lib/python3.10/site-packages/pip/_internal/cli/main.py", line 70, in main
return command.main(cmd_args)
File "/app/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 101, in main
return self._main(args)
File "/app/lib/python3.10/site-packages/pip/_internal/cli/base_command.py", line 223, in _main
self.handle_pip_version_check(options)
File "/app/lib/python3.10/site-packages/pip/_internal/cli/req_command.py", line 190, in handle_pip_version_check
pip_self_version_check(session, options)
File "/app/lib/python3.10/site-packages/pip/_internal/self_outdated_check.py", line 236, in pip_self_version_check
logger.warning("[present-rich] %s", upgrade_prompt)
File "/usr/lib/python3.10/logging/__init__.py", line 1489, in warning
self._log(WARNING, msg, args, **kwargs)
File "/usr/lib/python3.10/logging/__init__.py", line 1624, in _log
self.handle(record)
File "/usr/lib/python3.10/logging/__init__.py", line 1634, in handle
self.callHandlers(record)
File "/usr/lib/python3.10/logging/__init__.py", line 1696, in callHandlers
hdlr.handle(record)
File "/usr/lib/python3.10/logging/__init__.py", line 968, in handle
self.emit(record)
File "/app/lib/python3.10/site-packages/pip/_internal/utils/logging.py", line 179, in emit
self.handleError(record)
Message: '[present-rich] %s'
Arguments: (UpgradePrompt(old='22.2.2', new='23.0.1'),)
Do you have another idea?
thanks
GG
- adrianinsaval
- Veteran
- Posts: 5541
- Joined: Thu Apr 05, 2018 5:15 pm
Re: how to install workbench Python dependencies for a flatpak build?
I have confirmed that installing python dependencies from the addon manager works, but for this the addon developer must declare the python dependencies. Try removing and reinstalling the addon so that you get prompted in the addon manager to install the dependecies and click yes.
If the dependency is not declared for the addon here's a workaround that I found by browsing the addon manager source code, in the FreeCAD python console run:
you can supply a list of python packages if required, not just one a time, for example:
if you are curious about the details on why this is the case, it turns out pip is too dumb to know it's running inside flatpak and installs the package to the regular user directory, which the flatpak doesn't actually uses later. The addon manager on the other hand is smart enough to know the flatpak data directory and uses a custom FreeCAD specific directory for python packages and passes this to pip. As for the error messages you get when running pip it turns out this is just related to pip's built-in version check so it doesn't affect the installation of packages, the addon manager thankfully disables this check.
If the dependency is not declared for the addon here's a workaround that I found by browsing the addon manager source code, in the FreeCAD python console run:
Code: Select all
import addonmanager_dependency_installer
depsInstaller = addonmanager_dependency_installer.DependencyInstaller([],['scipy'],[])
depsInstaller._install_python_packages()
Code: Select all
import addonmanager_dependency_installer
depsInstaller = addonmanager_dependency_installer.DependencyInstaller([],['scipy','py_slvs'],[])
depsInstaller._install_python_packages()
if you are curious about the details on why this is the case, it turns out pip is too dumb to know it's running inside flatpak and installs the package to the regular user directory, which the flatpak doesn't actually uses later. The addon manager on the other hand is smart enough to know the flatpak data directory and uses a custom FreeCAD specific directory for python packages and passes this to pip. As for the error messages you get when running pip it turns out this is just related to pip's built-in version check so it doesn't affect the installation of packages, the addon manager thankfully disables this check.
- adrianinsaval
- Veteran
- Posts: 5541
- Joined: Thu Apr 05, 2018 5:15 pm
Re: how to install workbench Python dependencies for a flatpak build?
@chennes would it be possible to offer the possibility of installing arbitrary python packages in the addon manager? I think there's still several addons around that don't properly declare their dependencies. Also, is there a way of installing dependencies of already installed addons if you chose not to during initial installation?
Re: how to install workbench Python dependencies for a flatpak build?
Yeah, it's something that we could add to the Python packages listing that's already there, I think. PRs welcome .
Re: how to install workbench Python dependencies for a flatpak build?
Hi,adrianinsaval wrote: ↑Thu Mar 16, 2023 2:09 pm I have confirmed that installing python dependencies from the addon manager works, but for this the addon developer must declare the python dependencies. Try removing and reinstalling the addon so that you get prompted in the addon manager to install the dependecies and click yes.
If the dependency is not declared for the addon here's a workaround that I found by browsing the addon manager source code, in the FreeCAD python console run:you can supply a list of python packages if required, not just one a time, for example:Code: Select all
import addonmanager_dependency_installer depsInstaller = addonmanager_dependency_installer.DependencyInstaller([],['scipy'],[]) depsInstaller._install_python_packages()
Code: Select all
import addonmanager_dependency_installer depsInstaller = addonmanager_dependency_installer.DependencyInstaller([],['scipy','py_slvs'],[]) depsInstaller._install_python_packages()
if you are curious about the details on why this is the case, it turns out pip is too dumb to know it's running inside flatpak and installs the package to the regular user directory, which the flatpak doesn't actually uses later. The addon manager on the other hand is smart enough to know the flatpak data directory and uses a custom FreeCAD specific directory for python packages and passes this to pip. As for the error messages you get when running pip it turns out this is just related to pip's built-in version check so it doesn't affect the installation of packages, the addon manager thankfully disables this check.
thanks for the code snippet! It works
I reinstalled and installed A3 again using the addon manager. Indeed A3 informs about its dependency on py_slvs, but when I confirm to install it nothing seems to happen and the dependency window from the addon manager remains empty. Then I ran the code snippet and restarted FC manually. After that I can import the modules and A3 also doesn't complain anymore.
Now I see another error:
Code: Select all
During initialization the error "[Errno 2] No such file or directory: '"/app/bin/python" -m pip install "/home/gg/.var/app/org.freecadweb.FreeCAD/data/FreeCAD/Mod/InventorLoader/./libs/olefile-0.46.zip"'" occurred in /home/gg/.var/app/org.freecadweb.FreeCAD/data/FreeCAD/Mod/InventorLoader/./InitGui.py
thanks
GG