Search code examples
pythonraspberry-pitypeerrorremote-accessremote-debugging

unsupported operand type(s) for <<: 'str' and 'int' strange behaviour of Python (Remote)


I saw many posts with this error but mine seems to be really strange. I have remote interpreter so, I works on windows with Pycharm and it's connected with my Raspberry pi3. Strange thing is that If I run code via pycharm it works like charm but if I go to raspberry console and here try to lunch script as a sudo python mycode.py it gives me this error

  unsupported operand type(s) for <<: 'str' and 'int'

So I have same code lunching in 2 ways and I get different result. What can cause it and how to fight it ?

code where it gives error :

v = ((bytes_arr[k] << 24) & 0xFF000000) | ((bytes_arr[k+1] << 16) & 0xFF0000) | \
            ((bytes_arr[k+2] << 8) & 0xFF00) | (bytes_arr[k+3] & 0xFF)

Solution

  • RPi sometimes use different python version than we think try to run it as sudo python3 mycode.py