wpilibsuite / WPILibPi

WPILib Raspberry Pi images designed for FRC (formerly FRCVision)
Other
87 stars 40 forks source link

Python - Missing Shebang Line Generates Cryptic Errors #97

Closed Sn3akyP3t3 closed 5 years ago

Sn3akyP3t3 commented 5 years ago

Huh... Import failed that's not a thing!... I wonder why that happened?

Turns out I forgot the shebang line #!/usr/bin/python3 a the top. Usually I never have to do that unless spawning the process from bash so maybe that is the cause of the problem.

These are the types of errors had when not adding the shebang: `./uploaded.py: 1: ./uploaded.py: import: not found

./uploaded.py: 2: ./uploaded.py: import: not found ./uploaded.py: 3: ./uploaded.py: import: not found ./uploaded.py: 4: ./uploaded.py: import: not found ./uploaded.py: 5: ./uploaded.py: import: not found ./uploaded.py: 7: ./uploaded.py: Syntax error: word unexpected (expecting ")")

Waiting 5 seconds... `

Perhaps its a dirty fix, but it should be solvable with SED to toss in a shebang for Python3 if the shebang is missing. I can't imagine any team really wanting to use Python 2, but that could be a reasonable blockade on the proposed solution.

PeterJohnson commented 5 years ago

I guess we could have runCamera run python3 uploaded.py instead of simply ./uploaded.py, which would also fix the issue.

Sn3akyP3t3 commented 5 years ago

Yep, that will solve that. Only problem would be any team that may insist in running Python 2 based apps. I doubt that is going on and there is little hope of gathering metrics on which team is running which code.

ThadHouse commented 5 years ago

Pynetworktables and the pi cscore require 3, so 2 would very much require their own stuff. So I don't think that's a huge issue.