ImportError: No module named Adafruit_SSD1306 Update

MRAB python at mrabarnett.plus.com
Thu Dec 5 15:55:42 EST 2019


On 2019-12-05 20:39, Joel Goldstick wrote:
> On Thu, Dec 5, 2019 at 3:31 PM RobH <rob at despammer.com> wrote:
>>
>> On 05/12/2019 19:40, Rhodri James wrote:
>> > On 05/12/2019 19:30, Rhodri James wrote:
>> >> On 05/12/2019 18:49, RobH wrote:
>> >>> Update:
>> >>> I did python3 Internet.py
>> >>> and now only get this error:
>> >>>
>> >>> pi at raspberrypi:~/Downloads $ python3 Internet.py
>> >>>    File "Internet.py", line 24
>> >>>      font = ImageFont.truetype( 'Minecraftia.ttf', 35)
>> >>>                                                      ^
>> >>> TabError: inconsistent use of tabs and spaces in indentation
>> >>>
>> >>> I cannot see what is wrong, as the text is all lined up with that
>> >>> above and below:
>> >>
>> >> The problem will be that you have a mix of tabs and spaces in your
>> >> indentation.  This causes problems because some people don't think
>> >> that the One True Tab Width is 8 characters ;-) so to them the
>> >> indentation looks ragged.  Worse, when they mix tabs and spaces, code
>> >> that looks to be at the same indentation level to them looks different
>> >> to the interpreter.  The decision was taken a while ago that Python
>> >> should put its foot down about this, and demand that we use either all
>> >> tabs or all spaces for our indentation.  That's what you've fallen
>> >> foul off; there must be a mix of tabs and spaces in that line!
>> >
>> > Or more likely you've used tabs on that line and spaces elsewhere, or
>> > vice versa.  I should have remember to say that, sorry.
>> >
>>
>> Ok thanks for the explanation there, and I have placed the cursor at the
>> beginning of the first indented line. Moving down 1 line at a time ,
>> each line is at the same position upto line 157 in the authors code .
>> Then it is closer in to the edge upto line 190, where it goes back out
>> again.
>>
>> What is my best course of action here now.
>>
> google or duckduckgo or whatever your text editor and tabs to spaces..
> there is probably an easy way to convert the file
> 
Or expand the tabs using Python: at the Python prompt, read it in, use 
the expandtabs method of str, write it back out.


More information about the Python-list mailing list