0

I have created a compiled python file. When I am executing the file using python command, then it is working fine like below.

$ python file.pyc

But, when I am putting ./ before the filename (file.pyc) like running a .sh file, then it is not working.It is throwing error.

$ ./file.pyc

It is having all the privileges (777).

Is there any way to execute the test.pyc file like we do with a test.sh file?

Regards, Sayantan

1 Answers1

1

Is there a specific reason you're using the .pyc file? Normally, you'd just add a shebang to the top of your script like so: #!/usr/bin/env python, modify permissions (777 is not necessary, 755 or even 744 would work), and run it $ ./file.py

Andrew Lamarra
  • 507
  • 2
  • 10
  • Thanks. I don't want the python code to be human-readable. So, I am compiling the same. And, yes adding the shebang is working for .py only. – Sayantan Mandal Apr 24 '17 at 15:10
  • In that case, see this answer: http://stackoverflow.com/questions/261638/how-do-i-protect-python-code. If you still want to do this (and need to create a Linux binary), look into [cx_Freeze](https://anthony-tuininga.github.io/cx_Freeze/) – Andrew Lamarra Apr 24 '17 at 16:02