"bad interpreter: Input/output error"

Jeffrey Walton noloader at gmail.com
Sun Jan 14 02:26:02 UTC 2024


On Sat, Jan 13, 2024 at 12:03 PM Ian Bruntlett <ian.bruntlett at gmail.com> wrote:
>
> On Sat, 13 Jan 2024 at 16:25, Jeff <atrocity at wywh.com> wrote:
>>
>> On 1/13/24 07:24, Ian Bruntlett wrote:
>>   > 3. Can you send the results of a hex dump of a faulty bash script to
>>  > here?
>>
>> Sure, here you go. I submitted this command:
>>
>> head -1 /mnt/WD8TBNAS03/Documents/ShellScripts/test.py | od -A x -t x1z -v
>>
>> and got this back:
>>
>> 000000 23 21 2f 75 73 72 2f 62 69 6e 2f 70 79 74 68 6f >#!/usr/bin/pytho<
>> 000010 6e 33 0a                                         >n3.<
>> 000013
>>
>> If I just submit test.py I get:
>>
>> bash: /mnt/WD8TBNAS03/Documents/ShellScripts/test.py: /usr/bin/python3:
>> bad interpreter: Input/output error
>
> I've compared your shebang (#!) statement's hex dump to an identical (working) one on my system. I found no differences.
>
> 0. I've done some searching about this. I think it is down to you storing your scripts on a NAS drive. Can you copy a script from the NAS drive and see if it will run OK from a local drive's directory? This webpage might be of interest: https://github.com/microsoft/WSL/issues/2969 . I think the NAS drive might be mounting as "noexec"

++.

Good find. I don't know how long that would have taken me to uncover.

> Failing that, here are some other ideas...
>
> 1. What is the output of:
> which python3
>
> 2. When you run test.py, and get the Input/Output error, what is the output of this command:
> echo $?
>
> 3. Try this as a script and see if it works:
> #!/usr/bin/env python3
> print ("Hello")

++ again. Shebang's using !#/bin/python3 or #1/usr/bin/python3 tickles
my pet peeves.

The POSIX way using the !#/usr/bin/env is just about always guaranteed
to work. Even on the BSDs, where stuff often goes in /usr/local.

> 4, Try this - it should get you into the python command line:
> $ env --debug python3

Jeff




More information about the ubuntu-users mailing list