About Us Knowledge Base Community Forum Electronics Toolbox FAQ Shipping & Delivery

Community Forum

Share your projects and post your questions

Search
Register or Sign In
Forum

Python 3 - No module named 'ow'

117 Views - Created 21 days ago

21 days ago

Posted by:
Ade9989

Users Avatar

Hi, 

I have a Pi4 with the ABelectronics 1-wire Pi Plus adaptor.

Running the latest Raspberry Pi official Raspian. All up to date. 

I have the I2C interface installed.  I have followed the setup notes in the Knowledge Base (I2C Part 2 - Enabling I²C on the Raspberry Pi)

And Knowledge Base  OWFS with I2C support on Raspberry Pi

service --status-all suggests that owftp,owhttp and owserver are all running.

I'm using the standard pre installed Thonny Python IDE. (ver 3.2.6) (seems to be python ver 3.7.3)

Copied the example code. Error : ModuleNotFoundError: No module named 'ow'

Read a previous Post, that had this issue (08/04/2020) and the sucessful help was to

sudo apt-get install python-ow python3-ow

But this returns: E: Unable to locate package python3-ow

(I did do: sudo apt-get update)

Help!

Many thanks...

20 days ago

Posted by:
andrew

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

Hi

Unfortunatley the python3-ow package is no longer available in the apt repository.

I found the following notes in the Debian owfs package change log.

owfs (3.2p3+dfsg1-2+deb10u1) buster; urgency=medium

  * Non-maintainer upload.
  * Drop python3-ow, python3-ownet: Unused, contained python2 code.
    (Closes: #943612)
owfs (3.2p3+dfsg1-5) unstable; urgency=medium
 * Remove python support (Closes: #937225, #943612)
    python3 will be re-added when upstream correctly support it
    python2 is not supported anymore in Debian

The python3-ow package may be added back in at a later date but for now the only option is to use Python 2.7 with the python-ow package

AB Electronics UK Tech Support

20 days ago

Posted by:
Ade9989

Users Avatar

Hi Andrew, 

Thank you for your reply... 

I'm a bit new to Raspberry / Linux and so whilst I see your words, I don't fully follow. Sorry. 

I believe that I have "the recommended" and most common setup for Pi - ie Raspian OS (Raspbian GNU/Linux 10 (buster)) and am using the preinstalled python IDE (Thonny), which is Python 3.7.3.

So.... why would this setup not be supported?

Python 2.x as I read is no longer supported, nor should be used(?): "As of January 1, 2020, the 2. x branch of the Python programming language is no longer supported by its creators, the Python Software Foundation".

Is there any route forwards to being able to use Python3 - perhaps with a different coding method or packages? When might the required package become availiable? (Who is the Upstream in: "python3 will be re-added when upstream correctly support it")?

FYI: There was no clue as to this issue when I purchased the "1 wire Pi Plus" cards....

 

Kind regards Adrian.

 

 

20 days ago

Posted by:
Ade9989

Users Avatar

Sorry - I should be clear and fair too.

I purchased via The Pi hut. 

But to aid others, the KB article "owfs-with-i2c-support-on-raspberry-pi" does say Step 1: Download the latest Raspbian linux image and burn to your SD Card... But due to what we are discussing above this doesn't quite work currently. 

Fingers crossed for a solution. 

Thanks. 

20 days ago

Posted by:
andrew

Last edited: 01/10/2020

Users Avatar

Location:
United Kingdom

Users Twitter  Users Website  

Hi Adrian

Python 3 is the current version but the group which maintains OWFS have not updated their python libraries for a while so until they decide to release a new version of the python3-ow library it will not be available to download using apt-get.  The upstream group in this case would be the Debian developers who maintain the Debian Linux distribution on which Raspbian Linux is based.  As they decided to remove python3-ow from their apt repositories it also vanished from the Raspbian repository.

There are other methods you can use to access the 1 Wire Pi Plus and connected devices that does not involve python3-ow.

If you have owfs installed you can access your 1 wire devices through the file system in the /mnt/1wire folder.

Inside the folder will be a list of devices, for example DS28B20 temperature sensors will have a name starting with "28." followed by their unique identifier.  To access the temperature of a sensor you open the temperature file inside the folder for that sensor "/mnt/1wire/28.0844C4030000/temperature".

To use the 1 wire devices in Python 3 the easiest method is to open the file and read the contents.  The code below shows a simple example for opening the temperature file from a DS28B20 and reading the temperature from the device every 10 seconds.

#!/usr/bin/python
import os
import time

def main():    
    device = "/mnt/1wire/28.0844C4030000/temperature"

    while True:
        temperature = open(device, "r")
        print (temperature.read())             
        time.sleep(10)
        

if __name__ == "__main__":
    main()

OWFS caches the values from each sensor and updates it periodically so you may get the same value returned several times before it updates.  If you need to access the current value from a sensor there is a /mnt/1wire/uncached folder which will fetch the data directly from the 1 wire devices when you open the file, for example "/mnt/1wire/uncached/28.0844C4030000/temperature".

AB Electronics UK Tech Support

20 days ago

Posted by:
Ade9989

Users Avatar

Hi, 

Thank you for this really clear and full answer. 

Yes, I have owfs installed (as per your KB instructions) and yes, the 1-wire devices show up in the /mnt/1wire/ folder. 

Your example code work good - using Thonny (Python3)

Many thanks (for your help and rapid responses)

Adrian

 

Note: documents in Portable Document Format (PDF) require Adobe Acrobat Reader 5.0 or higher to view, download Adobe Acrobat Reader or other PDF reading software for your computer or mobile device.