7

I'm using nuitka to compile my python codes. I use --module option to import my code inside other python files:

nuitka --module --recurse-none file.py
Output: file.so

If I don't need to import the code and just need to run on terminal, I'm following regular compiling process:

nuitka --recurse-none file.py
Output: file.exe

I'm compiling these files under Debian and they work without a problem under Debian. When I move these files to an Ubuntu system, I sometimes get Segmentation Fault errors. Is it because a compiled python code under Debian is not compatible with Ubuntu or am I doing a personal mistake (like missing library etc.)

JayGatsby
  • 1,541
  • 6
  • 21
  • 41
  • 3
    Ubuntu is a debian linux. But you have provided very little information either about the error, or the platforms. – ChuckCottrill Apr 14 '18 at 01:21
  • 3
    I haven't kept up to date on `nuitka`, but don't you need to use `--standalone` to make an executable portable to even a nearly-identical machine? – abarnert Apr 14 '18 at 02:54

3 Answers3

2

As answered by abarnert, if you want to make your executable independent from the specific python installation on your device, you need to use the --standalone option.

You can check that info in the Nuitka Manual

Evil Platypus
  • 374
  • 2
  • 6
1

Dynamic Linking

From the docs,

It translates the Python into a C level program that then uses "libpython" to execute in the same way as CPython does.

Do you have libpython installed and pointing to the same version as the one you are compiling from? Example, on arch:

$ whereis libpython
libpython: /usr/lib/libpython3.so

Shows I have libpython installed and belonging to python 3.x (notice 3 at end of path).

Static linking.

The other way to do is I guess as suggested by others, i.e, using --standalone option. This should avoid the need of libpython

Varun Garg
  • 2,464
  • 23
  • 37
0

I'm kind of suspicious that you have your hint right in your question. *.exe is generally a Windows executable, while *.so is a UNIX/Linux reloadable module. Without delving into the manual very far, I notice that in one example you have --module and you get, sure enough, a Linux module. In the other case, you don't. And you don't.

Charlie Martin
  • 110,348
  • 25
  • 193
  • 263
  • "The created binaries have an ".exe" suffix, that you are free to remove that and yes, they are still Linux binaries. The suffix is just to be sure that the original script name and the binary name do not collide." http://nuitka.net/doc/user-manual.html – JayGatsby Apr 14 '18 at 01:06
  • Cool. So why is `--module` missing? – Charlie Martin Apr 14 '18 at 21:11