ModuleNotFoundError: No module named 'win10toast' ; bs4.FeatureNotFound: Couldn't find a tree builder with the features you requested: lxml

蹲街弑〆低调 提交于 2021-01-29 02:47:33

问题


I have already installed both of them using the pip command and it shows it is installed and yet is not working. I have also updated the version of pip still it shows the command to update the 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:


Let's break down what is happening:

  1. Your pip install lxml command resulted in an already satisfied error in the folder "...python\python37\lib\site-packages..."
  2. pip3 install lxml resulted in an already satisfied error in the folder "...python\python37\lib\site-packages..."

So both your pip and pip3 were pointing to the python distribution installed in "...python\python37, but when you execute your script, bs4 is imported from "...Python\Python37-32\lib\site-packages..." (note that Python37-32 is different from the paths pip pointed to). This leads me to believe that you somehow have two different python installations side by side and that pip and python point to different ones, which creates a mess.

In the comments you say that you have installed anaconda, which of course is now a third python distribution. In order to clear this up, I would recommend to

  1. Uninstall the python installations you had before, afterwards, make sure that both the "...Python\Python37-32\lib\site-packages..." and "...python\python37\lib\site-packages..." are gone/emptied
  2. Make sure that all commands like python pip are now all pointing to your anaconda installation
  3. Create and activate a virutal environment for your project (if desired)
  4. Install bs4: conda install -c anaconda beautifulsoup4 and win10toast:pip install win10toast

Now all imports should be working fine



来源:https://stackoverflow.com/questions/58267660/modulenotfounderror-no-module-named-win10toast-bs4-featurenotfound-couldn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!