Issues with pythonically importing FreeCAD (after conda install)

Need help, or want to share a macro? Post here!
roxanebruhwyler
Posts: 5
Joined: Thu Feb 18, 2021 2:52 pm

Issues with pythonically importing FreeCAD (after conda install)

Postby roxanebruhwyler » Thu Feb 18, 2021 4:08 pm

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
Posts: 10401
Joined: Thu Jan 05, 2017 9:03 pm

Re: import FreeCAD

Postby Kunda1 » Thu Feb 18, 2021 4:11 pm

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:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
heda
Posts: 352
Joined: Sat Dec 12, 2015 5:49 pm

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

Postby heda » Thu Feb 18, 2021 7:08 pm

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

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

Postby looo » Thu Feb 18, 2021 11:01 pm

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)

Postby roxanebruhwyler » Fri Feb 19, 2021 2:20 pm

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

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

Postby Kunda1 » Fri Feb 19, 2021 2:33 pm

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:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
roxanebruhwyler
Posts: 5
Joined: Thu Feb 18, 2021 2:52 pm

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

Postby roxanebruhwyler » Fri Mar 12, 2021 1:22 pm

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
Posts: 10401
Joined: Thu Jan 05, 2017 9:03 pm

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

Postby Kunda1 » Fri Mar 12, 2021 1:51 pm

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:
#lowhangingfruit | Use the Source, Luke. | How to Help FreeCAD | How to report FC bugs and features
roxanebruhwyler
Posts: 5
Joined: Thu Feb 18, 2021 2:52 pm

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

Postby roxanebruhwyler » Fri Mar 12, 2021 2:17 pm

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)

Postby roxanebruhwyler » Fri Mar 12, 2021 2:31 pm

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