Python ModuleNotFoundError:没有名为';win10toast';bs4.FeatureNotFound:无法';t找不到具有所需功能的树生成器:lxml

Python ModuleNotFoundError:没有名为';win10toast';bs4.FeatureNotFound:无法';t找不到具有所需功能的树生成器:lxml,python,python-3.x,pip,Python,Python 3.x,Pip,我已经使用pip命令安装了这两个组件,它显示它已经安装,但仍然不工作。我还更新了pip的版本,但它仍然显示了更新pip的命令 C:\Users\DELL>pip install win10toast Requirement already satisfied: win10toast in c:\users\dell\appdata\local\programs\python\python37\lib\site-packages (0.9) Requirement a

我已经使用pip命令安装了这两个组件,它显示它已经安装,但仍然不工作。我还更新了pip的版本,但它仍然显示了更新pip的命令

    C:\Users\DELL>pip install win10toast
    Requirement already satisfied: win10toast in c:\users\dell\appdata\local\programs\python\python37\lib\site-packages (0.9)
    Requirement already satisfied: setuptools in c:\users\dell\appdata\local\programs\python\python37\lib\site-packages (from win10toast) (40.8.0)
    Requirement already satisfied: pypiwin32 in c:\users\dell\appdata\local\programs\python\python37\lib\site-packages (from win10toast) (223)
    Requirement already satisfied: pywin32>=223 in c:\users\dell\appdata\local\programs\python\python37\lib\site-packages (from pypiwin32->win10toast) (225)
    You are using pip version 19.0.3, however version 19.2.3 is available.
    You should consider upgrading via the 'python -m pip install --upgrade pip' command.

    C:\Users\DELL>cd C:\Users\DELL\desktop

    C:\Users\DELL\Desktop>python test.py
    Traceback (most recent call last):
      File "test.py", line 3, in <module>
        from win10toast import ToastNotifier
    ModuleNotFoundError: No module named 'win10toast'
C:\Users\DELL>pip安装win10toast
已满足要求:c:\users\dell\appdata\local\programs\python\python37\lib\site软件包中的win10toast(0.9)
已满足要求:c:\users\dell\appdata\local\programs\python\python37\lib\site软件包中的setuptools(来自win10toast)(40.8.0)
已满足要求:c:\users\dell\appdata\local\programs\python\python37\lib\site软件包中的pypiwin32(来自win10toast)(223)
已满足要求:c:\users\dell\appdata\local\programs\python\37\lib\site软件包中的pywin32>=223(来自pypiwin32->win10toast)(225)
您使用的是pip版本19.0.3,但版本19.2.3可用。
您应该考虑通过Python -M PIP安装升级PIP命令进行升级。
C:\Users\DELL>cd C:\Users\DELL\desktop
C:\Users\DELL\Desktop>python test.py
回溯(最近一次呼叫最后一次):
文件“test.py”,第3行,在
从win10toast导入到ASTNotifier
ModuleNotFoundError:没有名为“win10toast”的模块
C:\Users\DELL\Desktop>pip安装lxml
已满足要求:c:\users\dell\appdata\local\programs\python\python37\lib\site软件包(4.4.1)中的lxml
您使用的是pip版本19.0.3,但版本19.2.3可用。
您应该考虑通过Python -M PIP安装升级PIP命令进行升级。
C:\Users\DELL\Desktop>pip3安装lxml
已满足要求:c:\users\dell\appdata\local\programs\python\python37\lib\site软件包(4.4.1)中的lxml
您使用的是pip版本19.0.3,但版本19.2.3可用。
您应该考虑通过Python -M PIP安装升级PIP命令进行升级。
C:\Users\DELL\Desktop>python test.py
回溯(最近一次呼叫最后一次):
文件“test.py”,第4行,在
soup=BeautifulSoup(源,“lxml”)
文件“C:\Users\DELL\AppData\Local\Programs\Python\Python37-32\lib\site packages\bs4\\uuuuuu init\uuuuu.py”,第196行,在\uuu init中__
%“,”。连接(功能))
bs4.FeatureNotFound:找不到具有您请求的功能的树生成器:lxml。您需要安装解析器库吗?

让我们来分析一下正在发生的事情:

  • 您的
    pip install lxml
    命令在文件夹
    “…python\python37\lib\site packages…”中导致了一个已满足要求的错误。
  • pip3 install lxml
    导致文件夹
    “…python\python37\lib\site packages…”中出现已满足要求的错误。
  • 因此,您的
    pip
    pip3
    都指向安装在中的
    python
    发行版
    “…python\python37
    ,但是当您执行脚本时,
    bs4
    “…python\python37-32\lib\site包导入…”
    (请注意,python37-32
    pip
    指向的路径不同)。这使我相信,不知何故,您有两个不同的
    python
    安装并排进行,
    pip
    python
    指向不同的安装,这造成了混乱

    在评论中,您说您已经安装了
    anaconda
    ,它现在当然是第三个
    python
    发行版

  • 卸载之前安装的
    python
    安装,然后确保
    “…python\Python37-32\lib\site包…”
    “…python\Python37\lib\site包…”
    都已删除/清空
  • 确保所有命令,如
    python
    pip
    现在都指向您的
    anaconda
    安装
  • 为项目创建并激活虚拟环境(如果需要)
  • 安装
    bs4
    conda安装-c anaconda beautifulsoup4
    win10toast
    pip安装win10toast

  • 现在,所有导入都应该正常工作了

    让我们分析一下发生了什么:

  • 您的
    pip install lxml
    命令在文件夹
    “…python\python37\lib\site packages…”中导致了一个已满足要求的错误。
  • pip3 install lxml
    导致文件夹
    “…python\python37\lib\site packages…”中出现已满足要求的错误。
  • 因此,您的
    pip
    pip3
    都指向安装在中的
    python
    发行版
    “…python\python37
    ,但是当您执行脚本时,
    bs4
    “…python\python37-32\lib\site包导入…”
    (请注意,python37-32
    pip
    指向的路径不同)。这让我相信,不知何故,您有两个不同的
    python
    安装并排进行,并且
    pip
    python
    指向不同的安装,这造成了混乱

    在评论中,您说您已经安装了
    anaconda
    ,它现在当然是第三个
    python
    发行版。为了澄清这一点,我建议

  • 卸载之前安装的
    python
    安装,然后确保
    “…python\Python37-32\lib\site包…”
    “…python\Python37\lib\site包…”
    都已删除/清空
  • 确保所有命令,如
    python
    pip
    现在都指向您的
    anaconda
    安装
  • 为项目创建并激活虚拟环境(如果需要)
  • 安装
    bs4
    conda安装-c anaconda beautifulsoup4
    win10toast
    pip安装win
    
    C:\Users\DELL\Desktop>pip install lxml
    Requirement already satisfied: lxml in c:\users\dell\appdata\local\programs\python\python37\lib\site-packages (4.4.1)
    You are using pip version 19.0.3, however version 19.2.3 is available.
    You should consider upgrading via the 'python -m pip install --upgrade pip' command.
    
    C:\Users\DELL\Desktop>pip3 install lxml
    Requirement already satisfied: lxml in c:\users\dell\appdata\local\programs\python\python37\lib\site-packages (4.4.1)
    You are using pip version 19.0.3, however version 19.2.3 is available.
    You should consider upgrading via the 'python -m pip install --upgrade pip' command.
    
    C:\Users\DELL\Desktop>python test.py
    Traceback (most recent call last):
      File "test.py", line 4, in <module>
        soup = BeautifulSoup(source,'lxml')
      File "C:\Users\DELL\AppData\Local\Programs\Python\Python37-32\lib\site-packages\bs4\__init__.py", line 196, in __init__
        % ",".join(features))
    bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml. Do you need to install a parser library?