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?
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Evil ctypes hack in python
- Correctly parse PDF paragraphs with Python
Yocto always runs in a virtualenv. But I've found a way to trick it to use python 3 :
Thanks all for your help !
Linux distributions slowly transfer to Python3 on an application by application basis, by adapting the shebang line to use Python 3.
CentOS 7, Ubuntu 14.4 LTS, Debian Jessy all default to Python2.7 if you type
python
on the commandline.If Yocto is installed using a package manager, it will be adapted to whatever works on the Linux distribution it works either with a generic sheband (loading
python
) or with an explicit one (loadingpython2
orpython2.7
.If you install Yocto yourself, and it might not work because the system you are on defaults to a python from the 3 series, you can adapt the shebang line from:
to
I assume that python2.7 will be available for a few years to come and installable on demands, even if python3 becomes the default on any of those distributions (just like python3 was available when not installed by default).
What you should consider when installing Yocto from source is run it in a
virtualenv
so that you setup a clean environment, that might be somewhat more work, depending on the dependencies, but ensures a clean working environment for your application, that cannot be broken by any system update of any packages. And if you do that your setup can even use a python2.7.X version different than that supplied by the Linux distribution.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.
to change this to default to python2 just change the symlink to point to /usr/bin/python2
The entire setup:
to automatically change to python2 add the export $PATH to sources/poky/oe-init-build-env , just before the other stuff gets sourced:
and then source the env:
The canonical solution here is to use virtualenv to create an environment where "python" is python 2.