I'm trying to use the nuitka tool to turn my python program into executable on ubuntu. It works fine if the program doesn't have any import statements but breaks when I use it on a program that imports something e.g.
test.py
import numpy
print "hello, world."
type this on commandline
nuitka --recurse-all --python-version=2.7 test.py
and gives me these errors
Nuitka:WARNING:/usr/lib/python2.7/dist-packages/numpy/numarray/functions.py:45: Cannot find 'copyreg' in package 'numpy.numarray' as absolute import.
Nuitka:WARNING:/usr/lib/python2.7/dist-packages/numpy/distutils/npy_pkg_config.py:11: Cannot find 'configparser' in package 'numpy.distutils' as absolute import.
Nuitka:WARNING:/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:1765: Cannot find 'Numeric' in package 'numpy.distutils' as absolute import.
Nuitka:WARNING:/usr/lib/python2.7/dist-packages/numpy/distutils/system_info.py:1770: Cannot find 'numarray' in package 'numpy.distutils' as absolute import.
Nuitka:WARNING:/usr/lib/python2.7/dist-packages/numpy/f2py/diagnose.py:48: Cannot find 'numpy_distutils' in package 'numpy.f2py' as absolute import.
Nuitka:WARNING:/usr/lib/python2.7/dist-packages/numpy/f2py/diagnose.py:87: Cannot find 'numpy_distutils.command.build_flib' in package 'numpy.f2py' as absolute import.
I don't know about your particular use case but I also faced similar Cannot find '' in Package errors when using nuitka.
I was using sqlalchemy and had a similar issue with configparser
.
After about a day of debugging I found out that Nuitka trips up with SWIG (Dynamically Loaded shared objects).
What it means basically is, some programs/modules try to increase compatibility by using conditional imports.
For eg:
If python_version==3.5:
import thislibrary
else:
import thatlibrary
specifically the configparser
library is named configparser
in python3 and ConfigParser
in python2.
So what basically is happening is that nuitka is trying to import python 3 stuff when you clearly are using python 2.
For me the fix was to modify the source code of sqlalchemy and change the if else
construct to:
import thatlibrary
You can find more information in this Guide written by Tom Sheffler
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