Bug#1049933: freecad-python3: Can't `import FreeCAD` (python3 PATH)

debian_reportbug_202005 at michaelaltfield.net debian_reportbug_202005 at michaelaltfield.net
Thu Aug 17 00:55:09 BST 2023


Package: freecad-python3
Version: 0.19.1+dfsg1-2+deb11u1
Severity: normal
X-Debbugs-Cc: debian_reportbug_202005 at michaelaltfield.net

Dear Maintainer,

Can you please either:

 1. Add '/usr/lib/freecad-python3/lib' to the default python sys.path or
 2. Change the path of the files in '/usr/lib/freecad-python3/lib' to
 some-path that's already in the default sys.path?

Currently, if a user installs freecad, runs the python3 console, and
tries to `import FreeCAD`, the get an error:

  user at disp7637:~$ python3
  Python 3.9.2 (default, Feb 28 2021, 17:03:44) 
  [GCC 10.2.1 20210110] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import FreeCAD
  Traceback (most recent call last):
    File "<stdin>", line 1, in <module>
  ModuleNotFoundError: No module named 'FreeCAD'
  >>> 

This occurs because the sys.path does not include
'/usr/lib/freecad-python3/lib/'

  user at disp7637:~$ python3
  Python 3.9.2 (default, Feb 28 2021, 17:03:44)
  [GCC 10.2.1 20210110] on linux
  Type "help", "copyright", "credits" or "license" for more information.
  >>> import sys
  >>> print( sys.path )
  ['', '/usr/lib/python39.zip', '/usr/lib/python3.9', '/usr/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/dist-packages', '/usr/lib/python3/dist-packages', '/usr/lib/python3.9/dist-packages']
  >>>

If a user simply adds '/usr/lib/freecad-python3/lib/' to their python
sys.path, then the `import FreeCAD` works as expected

  >>> sys.path.append( '/usr/lib/freecad-python3/lib' )
  >>> import FreeCAD
  >>>

One solution is to update python so that the default sys.path includes
this directory.

Another solution is to change this directory to be inside one of the
default sys.path directories.

Finally, a symlink may be added to fix this issue.

For more information, please see:

 * https://forum.freecad.org/viewtopic.php?p=700032#p700032
 * https://unix.stackexchange.com/questions/754182/how-to-import-freecad-in-cli-python


Thank you,

Michael Altfield
https://www.michaelaltfield.net
PGP Fingerprint: 0465 E42F 7120 6785 E972  644C FE1B 8449 4E64 0D41

-- System Information:
Debian Release: 11.7
  APT prefers oldstable-security
  APT policy: (500, 'oldstable-security'), (500, 'oldstable')
Architecture: amd64 (x86_64)

Kernel: Linux 6.1.35-1.qubes.fc32.x86_64 (SMP w/2 CPU threads; PREEMPT)
Kernel taint flags: TAINT_BAD_PAGE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages freecad-python3 depends on:
ii  freecad-common             0.19.1+dfsg1-2+deb11u1
ii  libc6                      2.31-13+deb11u6
ii  libfreecad-python3-0.19    0.19.1+dfsg1-2+deb11u1
ii  libgcc-s1                  10.2.1-6
ii  libpython3.9               3.9.2-1
ii  libqt5core5a               5.15.2+dfsg-9
ii  libqt5gui5                 5.15.2+dfsg-9
ii  libqt5widgets5             5.15.2+dfsg-9
ii  libstdc++6                 10.2.1-6
ii  python3-matplotlib         3.3.4-1
ii  python3-pivy               0.6.5-1+b3
ii  python3-ply                3.11-4
ii  python3-pyside2.qtcore     5.15.2-1
ii  python3-pyside2.qtgui      5.15.2-1
ii  python3-pyside2.qtsvg      5.15.2-1
ii  python3-pyside2.qtuitools  5.15.2-1
ii  python3-pyside2.qtwidgets  5.15.2-1
ii  python3-pyside2.qtxml      5.15.2-1
ii  python3-yaml               5.3.1-5

freecad-python3 recommends no packages.

freecad-python3 suggests no packages.

-- no debconf information



More information about the debian-science-maintainers mailing list