'module' Object Has No Attribute 'to_bytes' Python
Please advise how I can cx-freeze my python program which uses serial : import serial import serial.tools.list_ports; print serial.tools.list_ports() Here's my se
Solution 1:
import sys
from cx_Freeze import setup, Executable
path = ["pystest"]+sys.path
build_exe_options = {"packages": ["os","serial"], "excludes": ["tkinter"],"path":path}
#add more package what are using for your app?
base = Noneif sys.platform == "win32":
base = "Win32GUI"
setup( name = "My test program",
version = "3.1",
description = "My test",
options = {"build_exe": build_exe_options},
executables = [Executable("pystest.py", base=base)])
Solution 2:
I actually ended up doing this :
- Modfying the file list_ports_windows.py inside C:\Python27\Lib\site-packages\serial\tools and changed serial to serialutil like this :
Ports = serialutil.to_bytes([80, 111, 114, 116, 115]) # "Ports"PortName = serialutil.to_bytes([80, 111, 114, 116, 78, 97, 109, 101]) # "PortName"
- Then Added
from serial import serialutil
to the imports
Not sure if this is the right or wrong way but then it worked.
Thanks.
Solution 3:
Ports = serial.to_bytes([80, 111, 114, 116, 115]) # "Ports" no attribute 'to_bytes' two step:
1、pip install pyserial==3.4
2、pip install pyserial==2.7
i don't know the reason, but it worked
Post a Comment for "'module' Object Has No Attribute 'to_bytes' Python"