简体   繁体   中英

MacOS Catalina, pip has installed packages but python cannot find them?

My pip has worked fine with my python 3 in the past and I have downloaded things such as pandas which all work fine in python. The problem I now encounter is any library I attempt to download using pip is not recognised by python. Here is how I have tried downloading skl.

pip install sklearn
pip3 install sklearn

When I input

pip list

or

pip3 list

Both list sklearn as being downloaded, however, when I go in python and input:

from sklearn import linear_model

I get the error

Traceback (most recent call last):
  File "/Users/nicross/Desktop/RainDance/RainFaller.py",line 8, in <module>
    from sklearn import linear_model
ModuleNotFoundError: No module named 'sklearn'

Any help solving this would be greatly appreciated.

python3 -m pip install sklearn

From the sklearn docs it looks like you might want to try:

pip install -U scikit-learn

(For more, try following the steps here: https://scikit-learn.org/stable/install.html and see if those fix it)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM