whaleygeek / bitio

A micro:bit I/O device library for Python
Other
92 stars 31 forks source link

Raspberry Pi Python 2 error VTIMESerial not found #4

Closed martinohanlon closed 7 years ago

martinohanlon commented 7 years ago

I received an error when trying to run bitio using Python 2 on the Pi, although I didnt receive the same error when running it on Python 2 on Windows:

Traceback (most recent call last):
  File "button.py", line 4, in <module>
    import microbit
  File "/home/pi/bitio/src/microbit/__init__.py", line 40, in <module>
    import serial
  File "/home/pi/bitio/src/microbit/serial/__init__.py", line 29, in <module>
    from serial.serialposix import Serial, PosixPollSerial, VTIMESerial  # noqa
ImportError: cannot import name VTIMESerial
whaleygeek commented 7 years ago

Sounds like an unsatisfied package dependency in pyserial, presumably a bug in the version 2 distribution. I'll keep a lookout for it. When I do some Pi testing I'll see if I can do a quick fix to stop this happening, as I don't need any of the time services in what I do.

whaleygeek commented 7 years ago

at the moment this is a wontfix, but I might upgrade the status later when I have more time to investigate properly.

whaleygeek commented 7 years ago

@martinohanlon I had a look into this. It turns out that VTIMESerial is an 'adaptor layer' that the pyserial author put in to step over a linux ttys bug. It's a bit historic now, and this github issue suggests it is no longer used:

https://github.com/pyserial/pyserial/issues/82

So, I took out the reference to VTIMESerial (as my pycharm editor marked it as grey to say it was not in use anyway and a grep shows it was not used anywhere explicitly). Changed in this commit:

https://github.com/whaleygeek/bitio/commit/5e8713eab137aa586ebba45cf780263c70f171bc

I've asked @gemmamaylatham to try it on her PiTop OS next time she gets a chance and to report back here.

I've been unable to replicate this at this end on my Mac or on my Pixel OS. Struggling to find all the necessary bits required to get my Pi booting at the moment.

But I think this should fix it.

whaleygeek commented 7 years ago

If it doesn't fix it, then you can temporarily turn on debug mode like this:

python counter.py debug

You will then get extra information at the point of failure. Added here: https://github.com/whaleygeek/bitio/commit/85287fef6678ee39ffed70eca53f3d31497f28f8

GemmaMayLatham commented 7 years ago

Just successfully cloned and run the counter code in Python 3

GemmaMayLatham commented 7 years ago

Python 2 working also

GemmaMayLatham commented 7 years ago

This is in latest PiTop Os with updates just run

whaleygeek commented 7 years ago

@gemmamaylatham great thanks for letting us know!

whaleygeek commented 7 years ago

@martinohanlon This issue is now fixed - can you re-test at your end to make sure the problem has gone away for you too? Thanks!

whaleygeek commented 7 years ago

@martinohanlon any update on whether this fixed your problem or not? Ta!

martinohanlon commented 7 years ago

@whaleygeek retested... This issue has now been resolved. Sorry for the delay.