问题
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:
- Your
pip install lxmlcommand resulted in an already satisfied error in the folder"...python\python37\lib\site-packages..." pip3 install lxmlresulted 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
- Uninstall the
pythoninstallations you had before, afterwards, make sure that both the"...Python\Python37-32\lib\site-packages..."and"...python\python37\lib\site-packages..."are gone/emptied - Make sure that all commands like
pythonpipare now all pointing to youranacondainstallation - Create and activate a virutal environment for your project (if desired)
- Install
bs4:conda install -c anaconda beautifulsoup4andwin10toast:pip install win10toast
Now all imports should be working fine
来源:https://stackoverflow.com/questions/58267660/modulenotfounderror-no-module-named-win10toast-bs4-featurenotfound-couldn