There's another python module called 'serial', that you might have on your system. I was using a program that imports the 'serial' module, and on my Linux machine it worked when executed by one user, and failed when executed as another user.
When running the program as user2, I got the following traceback:
Traceback (most recent call last):
File "./grabserial", line 957, in <module>
restart_requested = grab(sys.argv[1:])
File "./grabserial", line 365, in grab
sd = serial.Serial()
AttributeError: 'module' object has no attribute 'Serial'
I figured out that I had the pyserial 'serial' module in /home/user1/.local/lib/python2.7/site-packages/serial/init.pyc, but that the other user was getting the serial module from /usr/local/lib/python2.7/dist-packages/serial.
There are two different python packages that present a module called 'serial' to the sytem.
One module is called 'serial' by pip (this one is a serialization library), and the other is called 'pyserial' (this one is a serial port handling library).
The simple fix, if what you want to do is use the serial port handling module, is to uninstall the serialization module with pip, and make sure
you have the 'pyserial' installed.
In my case, I was using a program that used python 2.7 on my machine, so
I did:
$ pip2 uninstall serial
$ pip2 install pyserial
I did this as 'root', so that the pyserial module would be installed
globally (for all users). Apparently, user1 had run pip to install pyserial
as a local package for their account (so it worked for that account), but in order for other users to to use the module, the module needed to be installed globally. Also, the conflict with the 'serial' module had to be resolved.
pip freeze
? Doing a fresh pip install in a clean environment with python 3.6 and pyserial 3.4 had no issue for me. – Posture