pySerial works fine in Python interpreter, but not standalone
I think it's probably a race condition between when the serial port is opened and when the data are sent. I'd probably stick a sleep in between the open and the write calls.
Alternatively, instead of using this library "serial" you might want to just open and write directly to the device, perhaps it's doing something funny (see the double open mentioned in other posts)
pySerial not working when stand alone
Try adding a delay after the serial port has been opened. May not be fully ready to go by the time data is going in/out. Just for safety do it on both platforms!
Basically sleep/delay after:
ser = serial.Serial(port_name, 9600)
and
Serial.begin(9600);
Python serial without pyserial
Looking around I found this example.
From the site:
arduinoserial.py is a Python port of Tod E. Kurt's arduino-serial.c program for communicating with an Arduino microcontroller board over a serial port. It only uses standard Python modules (notably termios and fcntl) and does not require any special serial communications modules.
Like Tod's program, you can use it from the command line.
Related Topics
Interfacing Python and Torch7(Lua) via Shared Library
How to Deal with Linux/Python Dependencies
How to Install Libpython2.7.So
Python Error - "Importerror: Cannot Import Name 'Dist'"
Killing Sudo-Started Subprocess in Python
Faster Way to Find Large Files with Python
Unresolved Reference Issue in Pycharm
How to Default Python3.8 on My MAC Using Homebrew
Python Valueerror: Embedded Null Byte When Reading Png File from Bash Pipe
Python Script Is Not Running Under Cron, Despite Working When Run Manually
How to Find the Target File's Full(Absolute Path) of the Symbolic Link or Soft Link in Python
How to Run Multiple Subprocesses via Fork()
How to Get the Python Call Stack with the Linux Perf
How to Sudo the Current Process
Syntax Error Near Unexpected Token '(' Python Script