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 Answer 1

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

Sign up to request clarification or add additional context in comments.

2 Comments

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.
In that case, see this answer: 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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.