Problem with Pyserial

Hi,
I'm trying to communicate between arduino and my pc.
For the moment is very simple , i just want to switch on a LED when i send data but it doesn't work.
I use pySerial. The problem is the following : when i send data to my arduino the led TX blinks but the part of my code wich is after if ( serial.available()>0) doesn't run.
Here is my code :

Python code :

import serial 


serie=serial.Serial() 	
serie.baudrate=9600
serie.port= 'COM10'
serie.parity=serial.PARITY_ODD
serie.stopbits=serial.STOPBITS_ONE
serie.bytesize=serial.EIGHTBITS

if serie.isOpen():
    serie.close()
serie.open()
serie.isOpen() 
serie.write("hello".encode())

Arduino code :

int ledPin = 9;
byte incomingByte;

void setup() {
    Serial.begin(9600);
    pinMode(ledPin, OUTPUT);
}

void loop() {
    
    if (Serial.available() > 0) {
        incomingByte = Serial.read();
        digitalWrite(ledPin, HIGH);
    }

    delay(1000);
    digitalWrite(ledPin, LOW);}

Thank you !

So the host computer is Windows 10 I am guessing?

What version of Python?

C:\Users\rsutherland>python
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 16:07:46) [MSC v.1900 32 bit (Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>

What version of PySerial?

[C:\Users\rsutherland>pip uninstall pyserial]
C:\Users\rsutherland>pip install pyserial
Collecting pyserial
  Using cached https://files.pythonhosted.org/packages/0d/e4/2a744dd9e3be04a0c0907414e2a01a7c88bb3915cbe3c8cc06e209f59c30/pyserial-3.4-py2.py3-none-any.whl
Installing collected packages: pyserial
Successfully installed pyserial-3.4

Have a look at this Python - Arduino demo

Your PC program should open the serial port, allow time for the Arduino to reset before trying to send data and should then keep the serial port open until it is completely finished with the Arduino.

...R

Yes I'm working with Windows 10.I have pyhton 3.6.4 and pyserial 3.4.
thank you ron_shutterland

I'm gonna test you program !
thank you Robin2

Most likely you are not waiting for the bootloader. I struggle with the encode and decode of the Python strings. Some of my programs encode 'ascii' for serial write and others encode 'utf-8'.

import serial, struct, time
ser = serial.Serial('COM10',9600, timeout=3)
time.sleep(3) # wait for the bootloader to run
if ser.in_waiting:
    junk = ser.readline().strip() # clean any junk from the buffer
    print("junk: " + junk[-10:].decode("utf-8")) 
a = ord('a') # send the code for 'a'
# Python 3.6 strings are utf-8, they seem to need encode to ascii for Pyserial
ser.write((chr(a)).encode('ascii'))
echo = ser.readline().strip()
print("debug: " + echo[-10:].decode("utf-8"))

There are more complex ways to send data with Python, an example I was looking at is

in that case, _connection.write is like your serie.write... unfortunately it is at the edge of what I can understand.