FreeCAD pip and get python packages into the FreeCAD python ecosystem

Here's the place for discussion related to coding in FreeCAD, C++ or Python. Design, interfaces and structures.
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Post Reply
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

FreeCAD pip and get python packages into the FreeCAD python ecosystem

Post by easyw-fc »

Hi,
with the latest ssl support, it easy to get pip
https://bootstrap.pypa.io/get-pip.py
and install pip on FC locally

Code: Select all

C:\FreeCAD_0.17\bin\python get-pip.py
then get python packages installed locally into the FreeCAD python ecosystem

Code: Select all

C:\FreeCAD_0.17\bin\python get-pip.py

Code: Select all

cd C:\FreeCAD_0.17\bin\
C:\FreeCAD_0.17\bin\Scripts\pip install <pkg_name>
In windows this is giving a fully python local environment, that can be called internally in FC or externally as for your needs.

To be tested in Linux and OSX to see if that could break any dependencies

Maurice
reference:
viewtopic.php?f=4&t=16163&p=133142#p133129
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: FreeCAD pip and get python packages into the FreeCAD python ecosystem

Post by sgrogan »

easyw-fc wrote: Wed Aug 03, 2016 8:35 am In windows this is giving a fully python local environment, that can be called internally in FC or externally as for your needs.
How do you call this internally, from the Python console?
"fight the good fight"
User avatar
easyw-fc
Veteran
Posts: 3633
Joined: Thu Jul 09, 2015 9:34 am

Re: FreeCAD pip and get python packages into the FreeCAD python ecosystem

Post by easyw-fc »

sgrogan wrote: Thu Mar 01, 2018 10:11 pm
easyw-fc wrote: Wed Aug 03, 2016 8:35 am In windows this is giving a fully python local environment, that can be called internally in FC or externally as for your needs.
How do you call this internally, from the Python console?
I meant that when you install a new python package using pip outside FreeCAD, the package is going to be installed in a way that makes it compatible to run later inside FreeCAD...
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: FreeCAD pip and get python packages into the FreeCAD python ecosystem

Post by looo »

this works for the simple (python only) packages. But this can fail for more difficult packages with compiled binaries (numpy, scipy,...) .

Pip is directly shipped with python3. So best is to push for python3 to get a more consistent environment for windows.
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: FreeCAD pip and get python packages into the FreeCAD python ecosystem

Post by sgrogan »

easyw-fc wrote: Fri Mar 02, 2018 6:26 pm I meant that when you install a new python package using pip outside FreeCAD, the package is going to be installed in a way that makes it compatible to run later inside FreeCAD...
I figured out you can do

Code: Select all

import pip
pip.main(['install'] + ['<package_name>']
from an external python console, but it doesn't work in the FreeCAD python console.
looo wrote: Fri Mar 02, 2018 6:37 pm Pip is directly shipped with python3. So best is to push for python3 to get a more consistent environment for windows.
But this only improves things if the whole libpack is ported to VC14. The same problem would exist if I upgraded to PY3 and compiled with VS2013(VC12).
"fight the good fight"
User avatar
looo
Veteran
Posts: 3941
Joined: Mon Nov 11, 2013 5:29 pm

Re: FreeCAD pip and get python packages into the FreeCAD python ecosystem

Post by looo »

But this only improves things if the whole libpack is ported to VC14. The same problem would exist if I upgraded to PY3 and compiled with VS2013(VC12).
for sure. But vs2013 + py3 make no sense at all I guess.
Post Reply