Python version used on a recent Ubuntu system
#1
Hi,

This is potentially a newbie question but I cannot find solid information about this on the Forum or with Google.

I have just built a xmbc-14.1-Helix from sources on my Ubuntu machine. The machine has got python-2.7 installed, so I ran configure with ./configure PYTHON_VERSION=2.7. It builds fine, but it doesn't run because of python.

It seems like kodi is actually using python modules form the machine installed version rather than the ones supposedly coming with the kodi release. I did a small hack to start kodi and work around a " AttributeError: 'module' object has no attribute 'pydebug'" error, but now when trying to run a python script (addons), I get:

Code:
Error Contents: No module named _struct
Traceback (most recent call last):
File "/home/pbureau/Software/xbmc-14.1-Helix/addons/service.xbmc.versioncheck/service.py", line 107, in <module> Main()
File "/home/pbureau/Software/xbmc-14.1-Helix/addons/service.xbmc.versioncheck/service.py", line 46, in __init__
                                                oldversion, version_installed, version_available, version_stable = _versioncheck()
File "/home/pbureau/Software/xbmc-14.1-Helix/addons/service.xbmc.versioncheck/service.py", line 52, in _versioncheck
                                                from lib.jsoninterface import get_installedversion, get_versionfilelist
File "/home/pbureau/Software/xbmc-14.1-Helix/addons/service.xbmc.versioncheck/lib/jsoninterface.py", line 29, in <module>
                                                import json as jsoninterface
File "/usr/lib/python2.7/json/__init__.py", line 108, in <module>
                                                from .decoder import JSONDecoder
File "/usr/lib/python2.7/json/decoder.py", line 5, in <module>
                                                import struct
File "/usr/lib/python2.7/struct.py", line 1, in <module>
                                                from _struct import *
ImportError: No module named _struct

So why is kodi using "/usr/lib/python2.7/struct.py", shouln't it be invoking modules coming with the Kodi sources? I there a way to make sure kodi will use the correct version of python?

Thank you for any help about this...

Pierre
Reply
#2
system python 2.7.x IS the correct version. Kodi does not ship its own python on linux(we do on all other platforms), since there is zero need to.

edit: the above is only true when you built kodi _without_ unified depends.
Reply
#3
Don't force PYTHON_VERSION for a native (as opposed to cross compile) build.
Let configure handle it.

Check if python is working properly regards the struct module.
Open console,
type:
Code:
python
then type:
Code:
import struct

If there is an error like in kodi.log - than there is a problem with your OS, borked packages etc.
If the console stays silent after import - than there may be something wrong with the way you are building Kodi.
Reply
#4
thank you for the replies.

I tried "import struct" from the python console (and a few other tests like dir(struct)) and it works fine, so it is definitely not a problem with the python install on the system.

I will try to rebuild it without PYTHON_VERSION.

Can you explain how you build kodi with or without "unified depends"?
Reply
#5
http://kodi.wiki/view/HOW-TO:Compile_XBMC_for_Ubuntu
https://github.com/xbmc/xbmc/blob/master...ADME.linux
Reply
#6
So I rebuilt kodi from scratch following the instructions (the only difference being I got the sources from git and not from a ppa repo).

I still get the same errors with python. As I reverted my workaround, I am back to the original error (which may be more explicit):
Code:
Traceback (most recent call last):
  File "/usr/lib/python2.7/site.py", line 562, in <module>
    main()
  File "/usr/lib/python2.7/site.py", line 544, in main
    known_paths = addusersitepackages(known_paths)
  File "/usr/lib/python2.7/site.py", line 271, in addusersitepackages
    user_site = getusersitepackages()
  File "/usr/lib/python2.7/site.py", line 246, in getusersitepackages
    user_base = getuserbase() # this will also set USER_BASE
  File "/usr/lib/python2.7/site.py", line 236, in getuserbase
    USER_BASE = get_config_var('userbase')
  File "/usr/lib/python2.7/sysconfig.py", line 579, in get_config_var
    return get_config_vars().get(name)
  File "/usr/lib/python2.7/sysconfig.py", line 478, in get_config_vars
    _init_posix(_CONFIG_VARS)
  File "/usr/lib/python2.7/sysconfig.py", line 338, in _init_posix
    makefile = _get_makefile_filename()
  File "/usr/lib/python2.7/sysconfig.py", line 331, in _get_makefile_filename
    return os.path.join(get_path('platstdlib').replace("/usr/local","/usr",1), "config" + (sys.pydebug and "_d" or ""), "Makefile")
AttributeError: 'module' object has no attribute 'pydebug'
Segmentation fault (core dumped)

I tried "sys.pydebug" in a python console and it is working fine, I have been bumping on this problem for some time, I really have no idea why python is not initialized properly when launched from Kodi...

For clarifications, this error occurs when Py_Initialize() is called in XBPython::InitializeEngine().... so I don't think it is related with any python code within xbmc.
Reply
#7
Are you getting this error when building or when trying to run already built Kodi?

I still think there is something wrong with your OS, but TBH I have no idea what's causing this error for you.

I've been running my own builds of Kodi git master since early Gotham alphas on x86_64 and now raspberry-pi(2),
never seen such errors, for a such a complex piece of software with a whole bunch of dependencies
the build scripts are very well written even for cross builds and if you follow the instructions in wiki/git it should give you a working build.
Reply
#8
full Debug Log please.

I suspect you simply have a broken addon.

edit: and why not use the kodi package we provide on our PPAs?
Reply
#9
HI, if i understand your edit, when i follow the wiki and try sudo apt-get build-dep xbmc i get the following :-

Reading package lists... Done
Building dependency tree
Reading state information... Done
Picking 'kodi' as source package instead of 'xbmc'
E: Unable to find a source package for kodi
Reply
#10
@asavah: I get this error when running a Kodi I just built (see the log file, i just added a few lines of Log to track the segfault)

http://goo.gl/EEH1lg

@wsnipex: I am trying to build Kodi because I am a developer and I would like to contribute. It may be something wrong with my OS, but I have never altered the pyhton install, I have even tried apt-get install --reinstall python2.7
Reply
#11
ok... I am running an apt-get purge python2.7, that's currently uninstalling half of my system... wish me good luck :-)

<edit> Exact same result after a clean install of python2.7 :-( <edit>
Reply
#12
for the sake on exclusion: Please try with a package from our PPA to see if that errors as well. Since you compiled 14.2, use the unstable PPA.

btw:
05:16:15 T:3078039296 NOTICE: GL_RENDERER = Mesa DRI Mobile Intel® GM45 Express Chipset x86/MMX/SSE2
05:16:15 T:3078039296 NOTICE: GL_VERSION = 2.1 Mesa 8.0.4

this is pretty old.. Not related to python though.
Reply
#13
ok, I just did a quick test, building this sample program:

Code:
#include "Python.h"
int main()
{
  char pySearchPath[] = "/usr/lib/python2.7/";
  Py_SetPythonHome(pySearchPath);
  Py_Initialize();
}

And I have the same result (without the segfault), so it is actually not related with XBMC source code. I guess it is a problem with libpython on my system, I am currently trying to rebuild it from source.
I am wondering how I can be the only one reporting this issue, as ubuntu is a very common platform, and the libpython I am using is the stock one form the ubuntu repo...
Reply
#14
I still don't get what you are on about. Why would you need to compile a C prog to test python?

Code:
$ python
Python 2.7.6 (default, Mar 22 2014, 22:59:56)
[GCC 4.8.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.pydebug
False
>>>
Reply
#15
@pbureau
Try renaming (mv) .kodi and/or .xbmc directories and start with a clean profile.
This should rule out addons and/or settings.

Building python from source and replacing the one provided by distro is a very bad idea.
Reply

Logout Mark Read Team Forum Stats Members Help
Python version used on a recent Ubuntu system0