Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

is compiled python file under debian is compatible with ubuntu

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.)

like image 838
JayGatsby Avatar asked Apr 14 '18 00:04

JayGatsby


2 Answers

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

like image 69
Evil Platypus Avatar answered Oct 05 '22 22:10

Evil Platypus


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

like image 28
Varun Garg Avatar answered Oct 06 '22 00:10

Varun Garg