More and more Linux distributions use python 3.x as default python, but Yocto still uses python 2.7. How to use Yocto with one of those distributions?
Yocto always runs in a virtualenv. But I've found a way to trick it to use python 2 , setting the default python and including it in PATH env variable:
$ source oe-init-build-env build
$ mkdir build/python-bin
$ ln -s /usr/bin/python2 build/python-bin/python
$ ln -s /usr/bin/python2-config build/python-bin/python-config
$ export PATH=$(pwd)/build/python-bin:${PATH}
Thanks all for your help !
You can fix it by overwriting the hosttools symlink yocto creates.. I managed to start the yocto build with the fix from Shan-x but it didn't build through.
Yocto sources a different env for all recipes.. Some of the recipes, especially from meta-openembedded require hosttools. These hosttools are for example python (which is then expected to be python2). This hosttools are then symlinked in build/tmp/hosttools and this gets added to $PATH.
python -> /usr/bin/python
to change this to default to python2 just change the symlink to point to /usr/bin/python2
The entire setup:
$ mkdir build/python-bin
$ ln -s /usr/bin/python2 build/python-bin/python
$ ln -s /usr/bin/python2-config build/python-bin/python-config
$ mkdir -p build/tmp/hosttools
$ ln -sf /usr/bin/python2 build/tmp/hosttools/python
to automatically change to python2 add the export $PATH to sources/poky/oe-init-build-env , just before the other stuff gets sourced:
diff --git a/oe-init-build-env b/oe-init-build-env
index e813230a98..c981358577 100755
--- a/oe-init-build-env
+++ b/oe-init-build-env
@@ -47,6 +47,8 @@ if [ -z "$OEROOT" ]; then
fi
unset THIS_SCRIPT
+export PATH=$(pwd)/build/python-bin:${PATH}
+
export OEROOT
. $OEROOT/scripts/oe-buildenv-internal &&
TEMPLATECONF="$TEMPLATECONF" $OEROOT/scripts/oe-setup-builddir || {
and then source the env:
$ source oe-init-build-env build
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With