ModuleNotFoundError:没有名为'win10toast'的模块; bs4.FeatureNotFound:找不到具有您请求的功能的树构建器:lxml

问题描述 投票:1回答:1

我已经使用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\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?
python python-3.x pip
1个回答
0
投票

让我们分解正在发生的事情:

  1. 您的pip install lxml命令在文件夹"...python\python37\lib\site-packages..."中导致已经满足的错误
  2. [pip3 install lxml导致文件夹"...python\python37\lib\site-packages..."]中已经满足的错误>
  3. 所以您的pippip3都指向安装在python,但是在执行脚本时,"...python\python37是从bs4导入的(请注意,Python37-32

"...Python\Python37-32\lib\site-packages..."指向的路径不同)。这使我相信您会以某种方式并排安装两个不同的pip,并且pythonpip指向不同的安装,这会造成混乱。

在注释中,您说您已经安装了python,现在它已经是第三个anaconda发行版。为了解决这个问题,我建议您>

  1. 卸载以前安装的python,然后确保python"...Python\Python37-32\lib\site-packages..."都已清空/清空
  2. 确保现在像"...python\python37\lib\site-packages..." python之类的所有命令都都指向pip安装
  3. 为您的项目创建并激活虚拟环境(如果需要)
  4. 安装anacondabs4conda install -c anaconda beautifulsoup4win10toast
  5. 现在所有进口货物都可以正常工作

© www.soinside.com 2019 - 2024. All rights reserved.