I was trying to create a class in python with 'RawIOBase' as given below.
try:
import io
except ImportError:
class Serial(PosixSerial, FileLike):
pass
else:
class Serial(PosixSerial, io.RawIOBase):
pass
I was trying to run this using Python 2.6, but it is displaying the error:
AttributeError: 'module' object has no attribute 'RawIOBase'
I read that RawIOBase is supported from Python 2.6 onwards.
Make sure you do not have another file named io.py
. If so, it could mask the io
module in the standard library. You can check which file is getting loaded as the io
module by printing print(io)
. It should return something like <module 'io' from '/usr/lib/python2.6/io.pyc'>
.
If there is such a module or package masking the standard lib module, the solution is to rename the non-standard io
module or package.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With