dulei@duleideMacBook-Pro ~ % python -V
Python 2.7.16
dulei@duleideMacBook-Pro ~ % where python
/usr/bin/python
pip3 install --upgrade pip
dulei@duleideMacBook-Pro ~ % pip3 install --upgrade pip
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: pip in ./Library/Python/3.8/lib/python/site-packages (21.2.4)
Collecting pip
Downloading pip-21.3.1-py3-none-any.whl (1.7 MB)
|████████████████████████████████| 1.7 MB 651 kB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 21.2.4
Uninstalling pip-21.2.4:
Successfully uninstalled pip-21.2.4
WARNING: The scripts pip, pip3 and pip3.8 are installed in '/Users/dulei/Library/Python/3.8/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed pip-21.3.1
dulei@duleideMacBook-Pro ~ % pip3 list
Package Version
---------- -------
imageio 2.9.0
numpy 1.21.2
Pillow 8.3.1
pip 21.3.1
setuptools 49.2.1
six 1.15.0
wheel 0.33.1
dulei@duleideMacBook-Pro ~ % pip3 list --outdated
Package Version Latest Type
---------- ------- ------ -----
imageio 2.9.0 2.13.3 wheel
numpy 1.21.2 1.21.4 wheel
Pillow 8.3.1 8.4.0 wheel
setuptools 49.2.1 59.6.0 wheel
six 1.15.0 1.16.0 wheel
wheel 0.33.1 0.37.0 wheel
pip3 install --upgrade 库名
dulei@duleideMacBook-Pro ~ % pip3 install --upgrade numpy
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: numpy in ./Library/Python/3.8/lib/python/site-packages (1.21.2)
Collecting numpy
Using cached numpy-1.21.4-cp38-cp38-macosx_11_0_arm64.whl (12.3 MB)
Installing collected packages: numpy
Attempting uninstall: numpy
Found existing installation: numpy 1.21.2
Uninstalling numpy-1.21.2:
Successfully uninstalled numpy-1.21.2
WARNING: The scripts f2py, f2py3 and f2py3.8 are installed in '/Users/dulei/Library/Python/3.8/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed numpy-1.21.4
dulei@duleideMacBook-Pro ~ % pip3 list --outdated
pip3 uninstall 库名
pip3 install numpy
dulei@duleideMacBook-Pro ~ % pip3 install numpy
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: numpy in ./Library/Python/3.8/lib/python/site-packages (1.21.2)
pip3 install scipy
dulei@duleideMacBook-Pro ~ % pip3 install matplotlib
Defaulting to user installation because normal site-packages is not writeable
Collecting matplotlib
Downloading matplotlib-3.5.1-cp38-cp38-macosx_11_0_arm64.whl (7.2 MB)
|████████████████████████████████| 7.2 MB 8.4 kB/s
Requirement already satisfied: pillow>=6.2.0 in ./Library/Python/3.8/lib/python/site-packages (from matplotlib) (8.3.1)
Requirement already satisfied: numpy>=1.17 in ./Library/Python/3.8/lib/python/site-packages (from matplotlib) (1.21.4)
Collecting packaging>=20.0
Downloading packaging-21.3-py3-none-any.whl (40 kB)
|████████████████████████████████| 40 kB 12 kB/s
Collecting cycler>=0.10
Downloading cycler-0.11.0-py3-none-any.whl (6.4 kB)
Collecting pyparsing>=2.2.1
Downloading pyparsing-3.0.6-py3-none-any.whl (97 kB)
|████████████████████████████████| 97 kB 18 kB/s
Collecting kiwisolver>=1.0.1
Downloading kiwisolver-1.3.2-cp38-cp38-macosx_11_0_arm64.whl (59 kB)
|████████████████████████████████| 59 kB 11 kB/s
Collecting fonttools>=4.22.0
Downloading fonttools-4.28.3-py3-none-any.whl (884 kB)
|████████████████████████████████| 884 kB 13 kB/s
Collecting python-dateutil>=2.7
Downloading python_dateutil-2.8.2-py2.py3-none-any.whl (247 kB)
|████████████████████████████████| 247 kB 11 kB/s
Requirement already satisfied: six>=1.5 in /Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/site-packages (from python-dateutil>=2.7->matplotlib) (1.15.0)
Installing collected packages: pyparsing, python-dateutil, packaging, kiwisolver, fonttools, cycler, matplotlib
WARNING: The scripts fonttools, pyftmerge, pyftsubset and ttx are installed in '/Users/dulei/Library/Python/3.8/bin' which is not on PATH.
Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
Successfully installed cycler-0.11.0 fonttools-4.28.3 kiwisolver-1.3.2 matplotlib-3.5.1 packaging-21.3 pyparsing-3.0.6 python-dateutil-2.8.2
pip3 install matplotlib
scikit-learn官网
pip3 install --pre --extra-index https://pypi.anaconda.org/scipy-wheels-nightly/simple scikit-learn
如下所示即为安装成功
dulei@duleideMacBook-Pro bp_demo % python3
Python 3.8.9 (default, Aug 3 2021, 19:21:54)
[Clang 13.0.0 (clang-1300.0.29.3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import scipy
>>> import numpy
>>> import sklearn
>>>
# coding=UTF-8
# coding=UTF-8
import matplotlib.pyplot as plt
import matplotlib as mpl
import numpy as np
x = np.linspace(0, 20, 100) # 创建在一定范围内间隔均匀数字列表
plt.plot(x, np.sin(x)) # 绘制每个x点的正弦值
plt.show() # 显示列表
此人抄袭MacOS安装python sklearn库等