Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

pySerial AttributeError: module 'serial' has no attribute 'Serial'

I have windows 7 64 bit and Python 3.6

I literally dig entire web for solving this - and nothing works sadly.

AttributeError                            Traceback (most recent call last)
<ipython-input-150-80ee8bd5f0f2> in <module>()
----> serial.Serial()

AttributeError: module 'serial' has no attribute 'Serial'

I tried solve this by: - checking if my file is named serial.py - reinstalling module - at first, entire module didn't work, now only it's functions. - I can't use any of its features, checking ports don't work, nothing works literally. - I checked my pip - everything is fine, module is in folder site-pacages. - If I execute some code inside pySerial files - it works. But there is no serial.Serial or connecting with COM ports (which I try to do.)

like image 617
TypoweEhhhh Avatar asked Nov 08 '17 23:11

TypoweEhhhh


2 Answers

I had the same problem with Python3 3.6.3.1 installed under Cygwin. I replaced 3.6.3.1 with 3.4.5.1 and the script worked again. OK, but not a good long term solution.

Better solution: I reinstalled Python3 3.6.3.1, and then did "pip install pyserial", and then I was able to run my script. No additional modules show up when I do help("modules"), but something extra must have been added to serial.

like image 109
cwilde Avatar answered Oct 13 '22 06:10

cwilde


If you are on a Windows machine using the Windows Subsystem for Linux (WSL), instead of a virtual machine, you will get this error. To fix it, go into powershell and enter the command:

wsl --shutdown

Restarting powershell, and running the pyautogui script again, worked.

like image 1
csfrancis555 Avatar answered Oct 13 '22 05:10

csfrancis555