如何在Windows上使用Python修复“从pexpect_serial导入SerialSpawn”错误?

我有一个使用pexpect,pyserial模块的旧脚本。在重新安装Windows之前,我运行得非常好。现在,如果不显示以下内容,我将无法使其正常工作;

Traceback (most recent call last):
  File "C:\Program Files\Guidance Automation Ltd\kingpiN Programming\KingpinProgramming.py",line 7,in <module>
    from pexpect_serial import SerialSpawn
  File "C:\Program Files\Python37\lib\site-packages\pexpect_serial\__init__.py",line 1,in <module>
    from .serial_spawn import SerialSpawn
  File "C:\Program Files\Python37\lib\site-packages\pexpect_serial\serial_spawn.py",line 24,in <module>
    from pexpect import spawn
ImportError: cannot import name 'spawn' from 'pexpect' (C:\Program Files\Python37\lib\site-packages\pexpect\__init__.py)

我尝试了安装pexpect_serial,pexpect和pyserial模块的多种组合,以及多种版本的python,但仍然无济于事。 pexpect-serial模块似乎有问题。

文件的开始显示如下:

import sys
import time
import os
import serial
import pexpect.fdpexpect
import pexpect.popen_spawn
from pexpect_serial import SerialSpawn
import paramiko
from config import *
wanglei89006 回答:如何在Windows上使用Python修复“从pexpect_serial导入SerialSpawn”错误?

所以,回答我的特定问题...

我不需要那个模块!我只是将代码修改为;

import sys
import time
import os
import serial
import pexpect.fdpexpect
import pexpect.popen_spawn
#from pexpect_serial import SerialSpawn
import paramiko
from config import *

因此它一直没有问题!

因此,事后看来,在沮丧地试图迫使它们正常工作之前,总是需要检查模块。

此外,我相信“从pexpect_serial导入SerialSpawn”在Windows上根本无法运行。

本文链接:https://www.f2er.com/3167286.html

大家都在问