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.
User avatar
easyw-fc
Posts: 2627
Joined: Thu Jul 09, 2015 9:34 am

FreeCAD pip and get python packages into the FreeCAD python ecosystem

Postby easyw-fc » Wed Aug 03, 2016 8:35 am

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
Posts: 5330
Joined: Wed Oct 22, 2014 5:02 pm

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

Postby sgrogan » 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?
User avatar
easyw-fc
Posts: 2627
Joined: Thu Jul 09, 2015 9:34 am

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

Postby easyw-fc » Fri Mar 02, 2018 6:26 pm

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...
looo
Posts: 2821
Joined: Mon Nov 11, 2013 5:29 pm

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

Postby looo » Fri Mar 02, 2018 6:37 pm

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
Posts: 5330
Joined: Wed Oct 22, 2014 5:02 pm

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

Postby sgrogan » Fri Mar 02, 2018 6:58 pm

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).
looo
Posts: 2821
Joined: Mon Nov 11, 2013 5:29 pm

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

Postby looo » Fri Mar 02, 2018 8:10 pm

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.