ImportError

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
jamyspoon
Posts: 2
Joined: Sat Feb 08, 2020 7:51 pm

ImportError

Post by jamyspoon »

Hi,

I have troubles importing FreeCAD in a Python script.
Following the example in https://www.freecadweb.org/wiki/Embedding_FreeCAD, my script is:

Code: Select all

#!/usr/bin/env python
# coding: utf-8

import sys

sys.path.append('/snap/freecad/8/opt/local/FreeCAD-0.18/lib')

import FreeCAD
And the error message I got when executing:

Code: Select all

Traceback (most recent call last):
  File "/home/jamal/PycharmProjects/OptiSav/processes/freecad_stl.py", line 16, in <module>
    import FreeCAD
ImportError: libFreeCADApp.so: cannot open shared object file: No such file or directory
libFreeCADApp.so is in the same directory that I add to sys, just like FreeCAD.so
When I try to import libFreeCADApp.so first, the ImportError points to libFreeCADBase.so. And when I try to import libFreeCADBase, the ImportError points to libxerces-c-3.1.so, which is present in '/snap/freecad/8/usr/lib/x86_64-linux-gnu'. Appending this directory to sys.path does not help.

Ubuntu 18.04.3 LTS 64bit
Python '3.7.6 (default, Jan 8 2020, 19:59:22) \n[GCC 7.3.0]'
FreeCAD 0.18, Libs: 0.18R16093 (Git)
vocx
Veteran
Posts: 5197
Joined: Thu Oct 18, 2018 9:18 pm

Re: ImportError

Post by vocx »

jamyspoon wrote: Sat Feb 08, 2020 8:19 pm ...
sys.path.append('/snap/freecad/8/opt/local/FreeCAD-0.18/lib')
...
I've seen nothing but issues with the Snap version of FreeCAD.

You should probably install the stable package or the daily that is available in PPAs.

See the instructions in Install on Unix. Alternatively, use the AppImage.
Always add the important information to your posts if you need help. Also see Tutorials and Video tutorials.
To support the documentation effort, and code development, your donation is appreciated: liberapay.com/FreeCAD.
jamyspoon
Posts: 2
Joined: Sat Feb 08, 2020 7:51 pm

Re: ImportError

Post by jamyspoon »

Hi, I reinstalled FreeCAD using conda and now it works. Cheers ! ;)
Post Reply