Bug 13147 - ImportError: No module named site OpenEmbedded requires 'python' to be python v2 (>= 2.7.3), not python v3.
Summary: ImportError: No module named site OpenEmbedded requires 'python' to be python...
Status: RESOLVED OBSOLETE
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 2.6.1
Hardware: x86 Multiple
: Medium normal
Target Milestone: 3.3
Assignee: Paul Eggleton
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2019-01-23 10:14 UTC by Robert Berger
Modified: 2021-04-29 15:25 UTC (History)
7 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Robert Berger 2019-01-23 10:14:45 UTC
I'm using a pre-release 2.6.1 version + extensible SDK.

When I run this from the extensible SDK (not bitbake cooker modus) I get:

+ devtool add nettoe https://github.com/RobertBerger/nettoe.git
+ press <ENTER> to go on

NOTE: Starting bitbake server...
ImportError: No module named site
OpenEmbedded requires 'python' to be python v2 (>= 2.7.3), not python v3.
Please upgrade your python v2.
NOTE: Starting bitbake server...
NOTE: Fetching git://github.com/RobertBerger/nettoe.git;protocol=https...

host# source environment-setup-armv7a-neon-poky-linux-gnueabi

host# which python3
/opt/ext-sdk/poky/2.6.1/multi-v7-ml/imx6q-phytec-mira-rdk-nand/buildtools/sysroots/x86_64-pokysdk-linux/usr/bin/python3

host# python3 --version
Python 3.5.6

host# which python
/usr/bin/python

host# python --version
Python 2.7.12

I thought we got rid of Python2 a long time ago for OE/Yocto.

Do I need to add Python 2 to my SDK now?

I am confused about the "upgrade" error.
Comment 1 Robert Berger 2019-01-23 10:26:23 UTC
Looks like it's bitbake, which comes with the SDK which complains about the Python version and not necessarily devtool.
Comment 2 Ross Burton 2019-01-24 15:44:00 UTC
That message isn't bitbake but oe-core:

scripts/oe-buildenv-internal:    echo >&2 "OpenEmbedded requires 'python' to be python v2 (>= 2.7.3), not python v3."

And indeed, OE still hard-requires Python 2 to be present because too many upstream still assume that Python 2 is present.  A few months ago I removed Py2 to see what broke and a not-insignificant amount of the system wouldn't build.

Maybe for 2.8 enough of the ecosystem will have migrated to Python 3 that we won't need to enforce this requirement, but for now you'll need both.

The good question is why you're getting an exception although the system claims to have python present.  Can you run python interactively and import site?  Is there a python binary inside the eSDK?
Comment 3 Robert Berger 2019-01-25 11:52:51 UTC
(In reply to comment #2)

> The good question is why you're getting an exception although the system
> claims to have python present.  Can you run python interactively and import
> site?

That's without the eSDK environment:

python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>> 

That's with the eSDK environment:

source environment-setup-armv7a-neon-poky-linux-gnueabi 
SDK environment now set up; additionally you may now run devtool to perform development tasks.
Run devtool --help for further details.
student@e450-1:/opt/ext-sdk/poky/2.6.1/multi-v7-ml/imx6q-phytec-mira-rdk-nand⟫ python
Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import site
>>> 

⟫which python
/usr/bin/python
⟫which python2
/usr/bin/python2
⟫which python2.7
/usr/bin/python2.7
⟫which python3
/opt/ext-sdk/poky/2.6.1/multi-v7-ml/imx6q-phytec-mira-rdk-nand/buildtools/sysroots/x86_64-pokysdk-linux/usr/bin/python3

> Is there a python binary inside the eSDK?

I checked in buildtools:

⟫find | grep python3$
./sysroots/x86_64-pokysdk-linux/usr/bin/python3

⟫ find | grep python2$

nothing

⟫ find | grep python$

nothing

in tmp/sysroots/x86_64:
./usr/bin/python-native/python2.7
./usr/bin/python-native/python2

in tmp/sysroots/x86_64:
./usr/bin/nativepython3
Comment 4 Stephen K Jolley 2019-01-25 17:03:00 UTC
Ross, it appears you NEEDINFO question has been answered. If you have questions put it back in NEEDINFO.
Comment 5 Ross Burton 2020-04-16 05:09:47 UTC
Bouncing to Paul as this is SDK related and he can look at it.  Note this is an old bug so may be obsolete by now.
Comment 6 Richard Purdie 2020-08-25 10:54:52 UTC
You can reproduce this bug with:

wget http://downloads.yoctoproject.org/releases/yocto/yocto-2.6.4/toolchain/x86_64/poky-glibc-x86_64-core-image-sato-armv5e-toolchain-ext-2.6.4.sh

then cd and source the env file, then

devtool add nettoe https://github.com/RobertBerger/nettoe.git

and you will see:

richard@jet:/tmp/rptest2$ devtool add nettoe https://github.com/RobertBerger/nettoe.git
NOTE: Starting bitbake server...
ImportError: No module named site
OpenEmbedded requires 'python' to be python v2 (>= 2.7.3), not python v3.
Please upgrade your python v2.
NOTE: Starting bitbake server...

but the command does complete successfully. The successful completion is probably why the automated tests don't catch it.

So the bug was definitely in 2.6.4.
Comment 7 Randy MacLeod 2021-04-29 15:25:04 UTC
python2 is no longer supported and 2.6.1 is in community support mode.