gpt4 book ai didi

python - ModuleNotFoundError : No module named 'win10toast' ; bs4. FeatureNotFound:找不到具有您请求的功能的树生成器:lxml

转载 作者:太空宇宙 更新时间:2023-11-03 20:19:00 24 4
gpt4 key购买 nike

我已经使用 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. 您的pip install lxml命令导致文件夹“...python\python37\lib\site-packages...”中出现已满足的错误<
  2. pip3 install lxml 在文件夹“...python\python37\lib\site-packages...”中导致已满足的错误

因此,您的 pippip3 都指向安装在的 python 发行版"...python\python37,但是当您执行脚本时,bs4 是从 "...Python\Python37-32\lib\site- 导入的packages...” (请注意,Python37-32pip 指向的路径不同)。这让我相信您以某种方式有两个不同的python 并排安装,并且 pippython 指向不同的安装,这会造成困惑。

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

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

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

关于python - ModuleNotFoundError : No module named 'win10toast' ; bs4. FeatureNotFound:找不到具有您请求的功能的树生成器:lxml,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58267660/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com