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

2024-04-15

我已经使用 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?

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

  1. Your pip install lxml命令导致文件夹中出现已满足的错误"...python\python37\lib\site-packages..."
  2. pip3 install lxml导致文件夹中出现已经满足的错误"...python\python37\lib\site-packages..."

所以你的pip and pip3正在指向python发行版安装在"...python\python37,但是当你执行脚本时,bs4是从进口的"...Python\Python37-32\lib\site-packages..."(注意Python37-32与路径不同pip指出)。这让我相信你有两种不同的python并排安装pip and python指向不同的,这会造成混乱。

在评论中你说你已经安装了anaconda,当然现在是第三个python分配。为了解决这个问题,我建议

  1. 卸载python您之前进行的安装,之后,请确保"...Python\Python37-32\lib\site-packages..." and "...python\python37\lib\site-packages..."消失/清空
  2. 确保所有命令都像python pip现在都指向你的anaconda安装
  3. 为您的项目创建并激活虚拟环境(如果需要)
  4. Install bs4: conda install -c anaconda beautifulsoup4 and win10toast:pip install win10toast

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

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

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

随机推荐