Python 3

From FreeCAD Documentation
Jump to navigation Jump to search
Other languages:
Deutsch • ‎English • ‎français • ‎italiano

The port of FreeCAD to Python 3 support is currently underway and progress is being tracked in this forum thread. The master branch of FreeCAD is already usable with python3. Tests are passing, but there are still many little incompatibilities. TESTERS WANTED!

This document is a placeholder for various platforms' build instructions and a checklist to monitor progress.

Building FreeCAD w/ Python 3

Ubuntu

The first step in building FreeCAD for Python 3 is ensuring you can build normally. Tip: It's also helpful to have a cmake GUI tool like cmake-qt-gui or cmake-curses-gui.

The following instructions are adapted from a post by looo in the Python 3 porting thread: Note: tested only with linux/ubuntu.

Download the current master of FreeCAD

 git clone https://github.com/FreeCAD/FreeCAD

If python3 is your default python then there shouldn't be much to do. If not I think the easiest is to do: Set the python relevant cmake variables with cmake-gui which are:

- PYTHON_EXECUTABLE
- PYTHON_INCLUDE_DIR
- PYTHON_LIBRARY
- PYTHON_BASENAME (=PySideConfigPYTHON_SUFFIX.cmake) -> for me on ubuntu this would be this: .cpython-35m-x86_64-linux-gnu
- PYTHON_SUFFIX (=ShibokenConfigPYTHON_SUFFIX.cmake) -> eg.: .cpython-35m-x86_64-linux-gnu

Pivy

python3 builds for freecad are available with this ppa

sudo add-apt-repository ppa:sppedflyer/mytestppa1
sudo apt-get update
sudo apt-get install python3-pivy

Pysidse

PySide for python3.5 isn't officially available, but I think ubuntu provides a build.

sudo apt-get install python3-pyside

Test builds on anaconda (linux64)

wget -c http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh
bash Miniconda-latest-Linux-x86_64.sh

and follow the instructions

once miniconda is installed we have to configure conda to have access to the freecad-builds:

conda config --add channels conda-forge
conda config --add channels freecad

now we create a new enviroment and install freecad

conda create --name freecad_py3 python=3.6 freecad

this will download all the necessary packages. When done activate the enviroment and start FreeCAD

source activate freecad_py3
FreeCAD

the first time you launch freecad, matplotlib loads some modules, and therefore FreeCAD will need some time to show up.

Alternate Install

Conda

Install miniconda: http://conda.pydata.org/miniconda.html

Install conda-build:

conda install conda_build

Add channels:

conda config --add channels freecad
conda config --add channels conda-forge

Clone the current Python 3 port of FreeCAD

git clone https://github.com/looooo/FreeCAD/tree/py3-27

Clone the conda-recipes for FreeCAD

git clone https://github.com/looooo/FreeCAD_Conda

- go to FreeCAD_Conda/.FreeCAD_debug

- set the variables on top of the script (the path to FreeCAD, and if you want to build with calling cmake)

conda build . --python=3.6 --dirty

(the dirty flag isn't necessary if you build the first time. If it isn't set conda does a full build all the time. The python option is not necessary if you have installed python3.6 miniconda version. But then you have to set this flag to build with python2.7....)

Links

  • Follow latest Pyside developments: