Issues with pythonically importing FreeCAD (after conda install)

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
roxanebruhwyler
Posts: 5
Joined: Thu Feb 18, 2021 2:52 pm

Issues with pythonically importing FreeCAD (after conda install)

Post by roxanebruhwyler »

Hello every body !

In order to use the python package OTSun (https://pypi.org/project/OTSun/), the libraries of FreeCAD must be available and included in my python path. So I install freecad in my working environment thank's to : conda install -c conda-forge freecad (https://anaconda.org/conda-forge/freecad). For information I work with anaconda prompt and I try with python 3.6.6 and python 3.8.
But when I try to import freecad (with import freecad or import FreeCAD), I have a message telling me : no module named 'FreeCAD'.
For information I dowloaded FreeCAD 0.18 before trying all of this. And the I try again after having uninstall it.

If you have any suggestion of what could be the problem it would be very nice !
Thank you in advance
Last edited by Kunda1 on Thu Feb 18, 2021 4:12 pm, edited 1 time in total.
Reason: made title more descriptive
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: import FreeCAD

Post by Kunda1 »

Mod edit; Moved to Python scripting subforum (though I was close to moving to Install/Compile since it's conda related)
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
heda
Veteran
Posts: 1348
Joined: Sat Dec 12, 2015 5:49 pm

Re: Issues with pythonically importing FreeCAD (after conda install)

Post by heda »

windows / linux / macos?
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: Issues with pythonically importing FreeCAD (after conda install)

Post by looo »

I think for 0.18 you need to modify the path. In 0.19 you should be able to import freecad via:

Code: Select all

import freecad
roxanebruhwyler
Posts: 5
Joined: Thu Feb 18, 2021 2:52 pm

Re: Issues with pythonically importing FreeCAD (after conda install)

Post by roxanebruhwyler »

Windows 10
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Issues with pythonically importing FreeCAD (after conda install)

Post by Kunda1 »

roxanebruhwyler wrote: Fri Feb 19, 2021 2:20 pm Windows 10
Full About info please
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
roxanebruhwyler
Posts: 5
Joined: Thu Feb 18, 2021 2:52 pm

Re: Issues with pythonically importing FreeCAD (after conda install)

Post by roxanebruhwyler »

Sorry for this late answer. I tried many things to make it works until my last post.
I am now on Ubuntu 20.4 with FeeCAD 0.18.4 (Python 3.8.5 (default, Jan 27 2021, 15:41:15) [GCC 9.3.0]) and I work on Pycharm community (Python 3.8.5 (default, Sep 4 2020, 07:30:14) [GCC 7.3.0]).

Things such as :

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

don't work. I rode that the aim is to give the path to the FreeCAD.so file but I don't understand why ? My objective is to be able to use FreeCAD module in my python interpreter and so to be able to import FreeCAD without any problems. For the moment, the message I get is "No module named "FreeCAD".

Thank you in advance for your time ...
User avatar
Kunda1
Veteran
Posts: 13434
Joined: Thu Jan 05, 2017 9:03 pm

Re: Issues with pythonically importing FreeCAD (after conda install)

Post by Kunda1 »

Kunda1 wrote: Fri Feb 19, 2021 2:33 pm
roxanebruhwyler wrote: Fri Feb 19, 2021 2:20 pm Windows 10
Full About info please
Please click the the About link to understand what we mean. Also please just update to v0.19_pre (or 0.19 stable if it's available for your OS).
Alone you go faster. Together we go farther
Please mark thread [Solved]
Want to contribute back to FC? Checkout:
'good first issues' | Open TODOs and FIXMEs | How to Help FreeCAD | How to report Bugs
roxanebruhwyler
Posts: 5
Joined: Thu Feb 18, 2021 2:52 pm

Re: Issues with pythonically importing FreeCAD (after conda install)

Post by roxanebruhwyler »

OS: Ubuntu 20.04.2 LTS
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.18.4.
Build type: Release
Python version: 3.8.2
Qt version: 5.12.5
Coin version: 4.0.0
OCC version: 7.3.0
Locale: French/France (fr_FR)
roxanebruhwyler
Posts: 5
Joined: Thu Feb 18, 2021 2:52 pm

Re: Issues with pythonically importing FreeCAD (after conda install)

Post by roxanebruhwyler »

Sorry, how am I supposed to update to the version you say ?
Post Reply