realthunder / FreeCAD

Link branch FreeCAD
Other
763 stars 45 forks source link

[Problem] Can't install/upgrade python modules with "pip" (flatpak version) #944

Open LinuksGuru opened 7 months ago

LinuksGuru commented 7 months ago

Is there an existing issue for this?

Version

0.21 (Development)

Full version info

[code]
OS: KDE Flatpak runtime (MATE//usr/share/xsessions/mate)
Word size of FreeCAD: 64-bit
Version: 2024.123.0.14555 (Git shallow)
Build type: Release
Branch: (HEAD detached at 20240123stable)
Hash: 0c0f69ad4806682096b51f7669d5f1cb83f9c7d7
Python 3.10.13, Qt 5.15.10, Coin 4.0.1, Vtk 8.2.0, OCC 7.6.3
Locale: English/United States (en_US)
Installed mods: 
  * freecad.gears 1.2.0
  * Assembly3 0.12.2
  * Assembly4 0.50.6
[/code]

Subproject(s) affected?

Other (specify in description)

Problem description

Hi!

For freecad.gears I'm need to install numpy version >= 1.21.6, while bundled version is 1.21.4. Running flatpak run --command=pip org.freecadweb.FreeCAD.Link install numpy==1.26.1 fails with error message: FileNotFoundError: [Errno 2] No such file or directory: '/usr/bin/pip' How to fix/get around this? Is there any other means to install/upgrade python packages from within? Thanks in advance.

Full log:

Lin@DESKTOP-NAPRDJL:~> flatpak run --command=pip org.freecadweb.FreeCAD.Link install numpy==1.26.1
Defaulting to user installation because normal site-packages is not writeable
Collecting numpy==1.26.1
  Downloading numpy-1.26.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.2 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 18.2/18.2 MB 5.2 MB/s eta 0:00:00
Installing collected packages: numpy
  WARNING: The script f2py is installed in '/var/data/python/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed numpy-1.26.3
--- 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.3.2'),)

Anything else?

No response

Code of Conduct

realthunder commented 6 months ago

Running pip that way in flatpak won't work, as it will install the package into the wrong directory. Please check out this thread for workaround.