Search code examples
pythonwxpythoncx-freezeopensuse

openSuse and cx_Freeze 4.3.3 : ImportError: libwx_gtk2u_adv-suse.so.1: No such file or directory


I'm trying to create a binary file with cx_Freeze 4.3.3 on openSuse 42.1 (I use wxPython3.0), but on an empty openSuse system, I can't run my program...

here is my setup.py file :

#!/usr/bin/python
# -*- coding: utf-8 -*-

import sys
from cx_Freeze import setup, Executable

path = sys.path
path += ["/usr/lib64"]

includes = []
excludes = ['PyQt4', 'PyQt5', 'Tkinter', 'FixTk', 'tcl', 'tk', '_tkinter', 'collections.abc']
packages = ['matplotlib.backends.backend_wxagg', 'numpy']

includefiles = ['./data/','./images/','./html/','./locale/','./logs/']

binpathincludes = []

if sys.platform == "linux2":
     binpathincludes += ["/usr/lib64"]
     binpathincludes += ["/usr/lib"]

base = 'Console'

options = {"path": path,
            "includes": includes,
            "excludes": excludes,
            "packages": packages,
            "include_files": includefiles,
            "bin_path_includes": binpathincludes,
            "optimize": 0,
            "silent": True
            }

executables = [
     Executable('MyProjetc.py', base=base)
]

setup(name='MyProject',
       version='1.0',
       description='My Project',
       executables=executables,
       options={'build_exe': options}
       )

but when I try to run my binary program on an empty system opensuse (without wxPython installed on it), I get this error :

Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/cx_Freeze/initscripts/Console.py", line 27, in <module>
File "JustConsum.py", line 4, in <module>
File "/usr/lib64/python2.7/site-packages/wx-3.0-gtk2/wx/__init__.py", line 45, in <module>
File "/usr/lib64/python2.7/site-packages/wx-3.0-gtk2/wx/_core.py", line 4, in <module>
File "ExtensionLoader_wx__core_.py", line 22, in <module>
File "ExtensionLoader_wx__core_.py", line 14, in __bootstrap__
ImportError: libwx_gtk2u_adv-suse.so.1: cannot open shared object file: No such file or directory

But that file "libwx_gtk2u_adv-suse.so.1" is indeed at root of the directory containing the binaries files :

-rwxrwx--- 1 regis users  1918960 25 oct.   2015 libwx_gtk2u_adv-suse.so.1
-rwxrwx--- 1 regis users   575528 25 oct.   2015 libwx_gtk2u_aui-suse.so.1
-rwxrwx--- 1 regis users  5780640 25 oct.   2015 libwx_gtk2u_core-suse.so.1

Any idea on what's going on ?

Thx a lot


Solution

  • So I searched on the internet, and found out the " patchelf " command. As my binary files (generated with cx_Freeze) were in the same directory than my executable file, I created the script :

    for i in *so*
    do
         patchelf --set-rpath '.' $i
    done
    

    Since, my standalone application can be launched on an "empty" openSuse system...

    Note:

    • this solution works with cx_Freeze 4.3.x, but don't with the 5.x versions

    • I successfully created standalone application (for this same program) on various other linux platform (Debian, Mint, Ubuntu, Mageia, Fedora, CentOS) without any kind of problem.

    • Only openSuse has needed this kind of operation so my standalone program can work out... I can't explain why.

    May be this post could help some else.