ImportError: No module named Adafruit_SSD1306 Update
MRAB
python at mrabarnett.plus.com
Thu Dec 5 14:28:43 EST 2019
On 2019-12-05 18:49, RobH wrote:
> On 05/12/2019 10:07, RobH wrote:
>> On 04/12/2019 23:15, Python wrote:
>>> Le 05/12/2019 à 00:06, RobH a écrit :
>>>> On 04/12/2019 22:33, Wildman wrote:
>>>>> On Wed, 04 Dec 2019 20:25:33 +0000, RobH wrote:
>>>>>
>>>>>> I am trying to do this project on a pi zero:
>>>>>>
>>>>>> http://frederickvandenbosch.be/?p=1365
>>>>>>
>>>>>> I copied the code to the pi zero Download folder and when I run it
>>>>>> I get
>>>>>> the above error at line 4
>>>>>> Import Adafruit_SSD1306
>>>>>>
>>>>>> I am using python version 2.7.16, if that makes any difference
>>>>>> I have the same module as the authors' link goes to :
>>>>>>
>>>>>> Monochrome 1.3" 128x64 OLED graphic display - STEMMA QT / Qwiic
>>>>>>
>>>>>> Have I missed something.
>>>>>
>>>>> The error indicates that Adafruit_SSD1306 in not installed.
>>>>>
>>>>> https://github.com/adafruit/Adafruit_Python_SSD1306
>>>>>
>>>>
>>>> I have the library in the same Downloads folder, but I don't know how
>>>> to actually install it as it doesn't have an .sh file included
>>>
>>> What cannot you understand in the Installing section of README.md?
>>>
>>> sudo python -m pip install --upgrade pip setuptools wheel
>>> sudo pip install Adafruit-SSD1306
>>>
>>> Or alternatively:
>>>
>>> sudo python -m pip install --upgrade pip setuptools wheel
>>> git clone https://github.com/adafruit/Adafruit_Python_SSD1306.git
>>> cd Adafruit_Python_SSD1306
>>> sudo python setup.py install
>>>
>>> even WORSE, what cannot you undertand at the top of same file?
>>>
>>> This library has been deprecated! We are leaving this up for
>>> historical and research purposes but archiving the repository.
>>>
>>>
>>
>> I was looking at the wrong file previously, and got mixed up, doh!
>> I have installed the Adafruit_Python_SSD1306 library now.
>>
>> (There is no mention that I can see about installing other libraries etc
>> to get the project to work, by the author)
>>
>
> 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:
>
Are you sure that the indentation is the same? Do all of the lines use
all spaces or all tabs or indentation? Just because they look lined-up
doesn't mean that they're doing it with the sequence of characters.
> def display_time():
> # Collect current time and date
> if(time_format):
> current_time = time.strftime("%I:%M")
> else:
> current_time = time.strftime("%H:%M")
>
> current_date = time.strftime("%d/%m/%Y")
>
> # Clear image buffer by drawing a black filled box
> draw.rectangle((0,0,width,height), outline=0, fill=0)
>
> # Set font type and size
> font = ImageFont.truetype ('Minecraftia.ttf', 35) << error here
>
> # Position time
> x_pos = (disp.width/2)-(string_width(font,current_time)/2)
> y_pos = 2 + (disp.height-4-8)/2 - (35/2)
>
>
More information about the Python-list
mailing list