Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error when trying to run example #11

Open
sbluatx opened this issue Jul 2, 2022 · 5 comments
Open

error when trying to run example #11

sbluatx opened this issue Jul 2, 2022 · 5 comments

Comments

@sbluatx
Copy link

sbluatx commented Jul 2, 2022

import serial
from pexpect_serial import SerialSpawn
Traceback (most recent call last):
File "", line 1, in
File "C:\python36\lib\site-packages\pexpect_serial_init_.py", line 1, in
from .serial_spawn import SerialSpawn
File "C:\python36\lib\site-packages\pexpect_serial\serial_spawn.py", line 24, in
from pexpect import spawn
ImportError: cannot import name 'spawn'

@sbluatx
Copy link
Author

sbluatx commented Jul 2, 2022

seems like from https://pexpect.readthedocs.io/en/stable/overview.html#windows pexpect.spawn is not available on windows

pexpect.version
'4.8.0'

@david-drinn
Copy link

david-drinn commented Jul 13, 2023

For my use case, I was using pexpect-serial on Windows for years. I'm not sure what changed in pexpect that removed that support. I'm guessing someone realized a technicality that is important for some use cases but not others, and removed support.

Looking to see which version of pexpect was used before where this worked.

EDIT: My guess that pexpect broke this was wrong. See below.

@david-drinn
Copy link

david-drinn commented Jul 13, 2023

pip install --force-reinstall -v "pexpect_serial==0.0.4" resolved this issue for me. That is, use version 0.0.4 of pexpect_serial, not 0.1.0.

@david-drinn
Copy link

4488ae4 appears to be the culprit commit that broke this in pexpect_serial.

@dancollins
Copy link

Running pip install pexpect-serial==0.0.4 on windows fixed it for me, too. Running Windows 11, miniconda and Python 3.11.

david-drinn referenced this issue Jul 31, 2023
- inherit from `pexpect.spawn` instead of `pexpect.SpawnBase`
- instead of implementing a new `read_nonblocking`, assign `self.child_fd = ser.fileno()` in the constructor and the spawn implementation works without any of the timeout issues
- sendline, write and writeline are no longer needed
- kill needs a new implementation as we only want to close the connection, there is no pid to kill
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants