Jump to content


Photo

using .so file with python: error,cannot open shared object file


  • Please log in to reply
13 replies to this topic

#1 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 29 July 2017 - 09:01

I am not familiar with c language,i use software called nuitka https://github.com/kayhayen/Nuitka to convert python module to c file with extension .so

i succeeded to import function from .so file in by using Ubuntu python but when tried to import the the same function from .so file in my et7500 box with python 2.7 gave me this error

root@et7x00:~# python /tmp/testobject.py
Traceback (most recent call last):
  File "/tmp/testobject.py", line 1, in <module>
    from printtext import print_text
ImportError: /var/volatile/tmp/printtext.so: cannot open shared object file: No
such file or directory
root@et7x00:~#

i put the .so and the test module in tmp path

attached the .so file and the python module to test the .so file

Attached Files



Re: using .so file with python: error,cannot open shared object file #2 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 29 July 2017 - 09:38

So you need to cross compile the .so for mips. Because .so are machine specific.
Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: using .so file with python: error,cannot open shared object file #3 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 29 July 2017 - 10:12

Thanks athoik

as i said i used the nuitka mentioned above to convert the python nodule to .so,The conversion completed in pc linux 32 bit with the already installed GCC

is there way to configure GCC to  compile the file specific to MIPS?

i found this library codescape-mips-sdk-essentials https://community.im...dk-essentials/ 

but do not know if im in the right way

sorry if asked selly question i am not familiar at all with this filed


Edited by mfaraj57, 29 July 2017 - 10:13.


Re: using .so file with python: error,cannot open shared object file #4 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 29 July 2017 - 10:44

I guess if you perform the procedure from devshell the produced so will be good for mips.

 

Using file xxx.so will tell you if produced for mips or not.


Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: using .so file with python: error,cannot open shared object file #5 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 29 July 2017 - 14:56

Thanks athoik

looks complicated but will give try and see



Re: using .so file with python: error,cannot open shared object file #6 MiLo

  • PLi® Core member
  • 14,055 posts

+298
Excellent

Posted 29 July 2017 - 15:03

If nuitka does what I think it does, it's actually a bad idea to do "compile" python modules on an embedded system. Instead of re-using what is already on the system, it embeds copies of everything, thus slowing things down and using more memory.

Just use the Python code on the box directly. Much easier and more efficient too.

Edited by MiLo, 29 July 2017 - 15:04.

Real musicians never die - they just decompose

Re: using .so file with python: error,cannot open shared object file #7 mfaraj57

  • Senior Member
  • 1,605 posts

+286
Excellent

Posted 29 July 2017 - 16:17

I am interested in more protection for python code(not for my code,nothing important to protect) so i think about .so as harder to decompile  in comparison with pyo or pyc files.


Edited by mfaraj57, 29 July 2017 - 16:21.


Re: using .so file with python: error,cannot open shared object file #8 Erik Slagter

  • PLi® Core member
  • 46,969 posts

+542
Excellent

Posted 17 August 2017 - 18:49

Exactly what I thought. This doesn't make sense. Don't do it. It won't do what you expect and it will only have drawbacks. Just another "copy protection: system and they're always the same.


* Wavefrontier T90 with 28E/23E/19E/13E via SCR switches 2 x 2 x 6 user bands
I don't read PM -> if you have something to ask or to report, do it in the forum so others can benefit. I don't take freelance jobs.
Ik lees geen PM -> als je iets te vragen of te melden hebt, doe het op het forum, zodat anderen er ook wat aan hebben.


Re: using .so file with python: error,cannot open shared object file #9 pcd

  • Senior Member
  • 759 posts

+88
Good

Posted 18 August 2017 - 13:52

One option is to 'obfuscate' the python code. Then it is extremely difficult to read.



Re: using .so file with python: error,cannot open shared object file #10 samsamsam

  • Senior Member
  • 2,024 posts

+146
Excellent

Posted 18 August 2017 - 14:49

Security through obscurity is no security at all. 

However, library written in the C sometimes is needed because of performance.

 

For example here:

https://github.com/s...r/iptvsubparser

 

is module written by me to speed up parsing external subtitles.

 

There is simple make.sh written in bash which call cross compiler directly .

I think it is easy to understand and learn how it is working from A to Z.

 

Regards,

SSS


Edited by samsamsam, 18 August 2017 - 14:51.


Re: using .so file with python: error,cannot open shared object file #11 MiLo

  • PLi® Core member
  • 14,055 posts

+298
Excellent

Posted 18 August 2017 - 17:38

Security through obscurity is no security at all. 
However, library written in the C sometimes is needed because of performance.


No argument with that. But that's not what the OP was doing.
 

There is simple make.sh written in bash which call cross compiler directly .
I think it is easy to understand and learn how it is working from A to Z.


For Python modules there's distutils. Use it.
Real musicians never die - they just decompose

Re: using .so file with python: error,cannot open shared object file #12 samsamsam

  • Senior Member
  • 2,024 posts

+146
Excellent

Posted 18 August 2017 - 22:20

There is many different utilities, but I will use what I like. 

I most like to call compiler directly. 

 

Regards,

SSS



Re: using .so file with python: error,cannot open shared object file #13 MiLo

  • PLi® Core member
  • 14,055 posts

+298
Excellent

Posted 23 August 2017 - 18:29

Sure, do as you please. Just don't make other people think that's a recommended way of doing things.

I like to build a steam engine. That doesn't mean that I'd recommend everyone to put one in their car...
Real musicians never die - they just decompose

Re: using .so file with python: error,cannot open shared object file #14 pcd

  • Senior Member
  • 759 posts

+88
Good

Posted 23 August 2017 - 19:59

You built a car with a steam engine ? WOW !!!




3 user(s) are reading this topic

0 members, 3 guests, 0 anonymous users