Support Forum

Share your projects and post your questions

Register   or   Sign In
The Forum

Python 3 - No module named 'ow'

The 1 Wire Pi Plus and 1 Wire Pi Zero are a 1 Wire interface for the Raspberry Pi

30/09/2020

Posted by:
Ade9989

Ade9989 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...

01/10/2020

Posted by:
andrew

andrew Avatar

Hi

Unfortunately, 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

01/10/2020

Posted by:
Ade9989

Ade9989 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.

01/10/2020

Posted by:
Ade9989

Ade9989 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.

01/10/2020

Posted by:
andrew

andrew Avatar

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 do 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 of 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".

01/10/2020

Posted by:
Ade9989

Ade9989 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

13/02/2021

Posted by:
lojzo2000

lojzo2000 Avatar

Ahoj bude Python 3 aktualizovaný ??

Python3-ow?



moja chyba

Traceback (posledný hovor posledný):
Súbor "/home/pi/1wiretest.py", riadok 1, v
importe ow
ModuleNotFoundError: Žiadny modul s názvom 'ow'




I still want to ask where to adjust the reading of the sensors every 50ms???

it is possible? DS2408 and DS18b20?

13/02/2021

Posted by:
andrew

andrew Avatar

Hello

Python3-ow is still not supported on Raspberry Pi OS so the easiest way to access the 1-Wire sensor is by opening the file in the /mnt/1wire/ directory.

Reading the temperature from the DS18B20 is slow in OWFS. Each sample will take more than 1 second to read so you will not be able to read your sensor every 50ms.

You can use the code below to test the sample speed of the DS18B20.


#!/usr/bin/python
import datetime
import numpy as N


def main():
# set the 1-Wire temperature sensor location and open the file
device = "/mnt/1wire/uncached/28.0844C4030000/temperature"

# number of samples to read
samples = 10

# create a counter and arrays to store the sampled temperatures
counter = 1
readarray = N.zeros(samples)

print("Starting Sample Capture")

starttime = datetime.datetime.now()

while counter < samples:
# read the temperate to the array
temperature = open(device, "r")
t = temperature.read()
temperature.close()
readarray[counter] = float(t)
counter = counter + 1

# stop the timer
endtime = datetime.datetime.now()

# calculate the samples per second
totalseconds = (endtime - starttime).total_seconds()
samplespersecond = samples / totalseconds

averagetemperature = N.average(readarray)

print("%.2f samples per seconds" % (samplespersecond))
print("Average Temperature: %.2f" % (averagetemperature))


if __name__ == "__main__":
main()

Sign in to post your reply


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.

Home

Shop

Learn

Forum

FAQ

Contact

0 item

Your cart is empty

Please browse our shop to order from the wide range of Raspberry Pi boards and accessories.

Subtotal:£0.00
View Basket Continue to Checkout