欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

no module named req

程序员文章站 2022-07-12 09:56:31
...

错误:

Traceback (most recent call last):
  File "dingdang.py", line 11, in <module>
    from client import tts
  File "/home/youzinan/zhou/robot/dingdang-robot-master/client/tts.py", line 32, in <module>
    from . import diagnose
  File "/home/youzinan/zhou/robot/dingdang-robot-master/client/diagnose.py", line 10, in <module>
    import pip.req
ImportError: No module named req
 

解决方案:

方案1

直接升级pip无效

方案2

直接在原函数中把import改为直接添加代码函数

def parse_requirements(filename):
    """ load requirements from a pip requirements file """
    lineiter = (line.strip() for line in open(filename))
    return [line for line in lineiter if line and not line.startswith("#")]