FG
💻 Software

How do *.pyc files execute?

Fresh5 days ago
Mar 15, 202617063 views
Confidence Score0%
0%

Problem

I noticed importing an executable Python file saves a *.py[co] file, as expected, but that file also is marked executable. Randomly, I wondered if I could execute this file directly, and it worked! Steps to duplicate: How did this work? Why didn't I get an error message? Is my system, Ubuntu 9.04, …

Error Output

$ echo 'print "Worked."' > testcase.py
$ chmod u+x testcase.py
$ python -c 'import testcase'
Worked.
$ ./testcase.pyc
Worked.

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Unverified Fix
New Fix – Awaiting Verification

Fix for: How do *.pyc files execute?

Low Risk

Perhaps your system has a binfmt_misc entry for files. Look in for the entry.

Awaiting Verification

Be the first to verify this fix

Sign in to verify this fix

Environment