注意:32位pip没有PaddlePaddle源
Python 3.7.4 => AIStudio NoteBook 环境中的版本,3.8 后期运行源码时会有问题
# 如果报下列错误,检查 Python 版本,不能过高也不要太低,并且不能是 32位的。 ERROR: Could not find a version that satisfies the requirement paddlepaddle=-2,4,2 (from versions: none) ERROR: No matching distribution found for paddlepaddle==2.4.2
百度飞桨(PaddlePaddle)官网:https://www.paddlepaddle.org.cn/install/quick
环境准备
本文安装 3.8.10 (其它项目用的版本,服务器推荐和 AI Studio 一至 3.7.6):https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe
# 查看 Python 的安装路径 D:\OpenSource\PaddlePaddle>where python D:\Program Files\Python38\python.exe C:\Users\cj218\AppData\Local\Microsoft\WindowsApps\python.exe # 确认 Python 版本是 3.6/3.7/3.8/3.9/3.10 D:\OpenSource\PaddlePaddle>python -V Python 3.8.10 D:\OpenSource\PaddlePaddle>python -m ensurepip Looking in links: c:\Users\cj218\AppData\Local\Temp\tmpk72khbsr Requirement already satisfied: setuptools in d:\program files\python38\lib\site-packages (56.0.0) Requirement already satisfied: pip in d:\program files\python38\lib\site-packages (21.1.1) D:\OpenSource\PaddlePaddle>python -m pip --version pip 21.1.1 from D:\Program Files\Python38\lib\site-packages\pip (python 3.8) D:\OpenSource\PaddlePaddle>python -c "import platform;print(platform.architecture()[0]);print(platform.machine())" 32bit AMD64 # 要求 pip 版本为 20.2.2 或更高版本 D:\OpenSource\PaddlePaddle>pip show pip Name: pip Version: 21.1.1 Summary: The PyPA recommended tool for installing Python packages. Home-page: https://pip.pypa.io/ Author: The pip developers Author-email: distutils-sig@python.org License: MIT Location: d:\program files\python38\lib\site-packages Requires: Required-by: # 如果需要升级,可以执行如下命令,或者,直接安装 python 高一点版本 D:\OpenSource\PaddlePaddle>python -m pip install --upgrade pip Collecting pip Downloading https://files.pythonhosted.org/packages/08/e3/57d4c24a050aa0bcca46b2920bff40847db79535dc78141eb83581a52eb8/pip-23.1.2-py3-none-any.whl (2.1MB) |████████████████████████████████| 2.1MB 656kB/s Installing collected packages: pip Found existing installation: pip 19.2.3 Uninstalling pip-19.2.3: Successfully uninstalled pip-19.2.3 Successfully installed pip-23.1.2
Paddlepaddle 安装
Mac终端出现 brew command not found 解决
python -m pip install paddlepaddle==2.4.2 -i https://pypi.tuna.tsinghua.edu.cn/simple
D:\OpenSource\PaddlePaddle>python -m pip install paddlepaddle==2.4.2 -i https://pypi.tuna.tsinghua.edu.cn/simple Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Collecting paddlepaddle==2.4.2 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/93/7b/0883c313d9513f5d77cf6ee71a9e9299630c9b912d13b39564d782dca465/paddlepaddle-2.4.2-cp38-cp38-win_amd64.whl (68.6 MB) |████████████████████████████████| 68.6 MB 90 kB/s Collecting numpy>=1.13 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/1a/62/af7e78a12207608b23e3b2e248fc823fbef75f17d5defc8a127c5661daca/numpy-1.24.3-cp38-cp38-win_amd64.whl (14.9 MB) |████████████████████████████████| 14.9 MB 133 kB/s Collecting opt-einsum==3.3.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/bc/19/404708a7e54ad2798907210462fd950c3442ea51acc8790f3da48d2bee8b/opt_einsum-3.3.0-py3-none-any.whl (65 kB) |████████████████████████████████| 65 kB 602 kB/s Collecting requests>=2.20.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/cf/e1/2aa539876d9ed0ddc95882451deb57cfd7aa8dbf0b8dbce68e045549ba56/requests-2.29.0-py3-none-any.whl (62 kB) |████████████████████████████████| 62 kB 239 kB/s Collecting decorator Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d5/50/83c593b07763e1161326b3b8c6686f0f4b0f24d5526546bee538c89837d6/decorator-5.1.1-py3-none-any.whl (9.1 kB) Collecting astor Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c3/88/97eef84f48fa04fbd6750e62dcceafba6c63c81b7ac1420856c8dcc0a3f9/astor-0.8.1-py2.py3-none-any.whl (27 kB) Collecting protobuf<=3.20.0,>=3.1.0 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/07/36/998db8bbde6980eff255a2701e16c871a950cbdc298ed9abe302f9301160/protobuf-3.20.0-cp38-cp38-win_amd64.whl (904 kB) |████████████████████████████████| 904 kB 6.8 MB/s Collecting paddle-bfloat==0.1.7 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/81/f1/fc22d4b77a63c76f42bac77d17eda76c789430656c2bd96176df8b4d183e/paddle_bfloat-0.1.7-cp38-cp38-win_amd64.whl (39 kB) Collecting six Downloading https://pypi.tuna.tsinghua.edu.cn/packages/d9/5a/e7c31adbe875f2abbb91bd84cf2dc52d792b5a01506781dbcf25c91daf11/six-1.16.0-py2.py3-none-any.whl (11 kB) Collecting Pillow Downloading https://pypi.tuna.tsinghua.edu.cn/packages/c3/ba/c4c2a1411561cd9725979115e7450f1367b44997ae1ff29e5845bce92d52/Pillow-9.5.0-cp38-cp38-win_amd64.whl (2.5 MB) |████████████████████████████████| 2.5 MB ... Collecting idna<4,>=2.5 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/fc/34/3030de6f1370931b9dbb4dad48f6ab1015ab1d32447850b9fc94e60097be/idna-3.4-py3-none-any.whl (61 kB) |████████████████████████████████| 61 kB 14 kB/s Collecting charset-normalizer<4,>=2 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/26/20/83e1804a62b25891c4e770c94d9fd80233bbb3f2a51c4fadee7a196e5a5b/charset_normalizer-3.1.0-cp38-cp38-win_amd64.whl (96 kB) |████████████████████████████████| 96 kB 796 kB/s Collecting urllib3<1.27,>=1.21.1 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/7b/f5/890a0baca17a61c1f92f72b81d3c31523c99bec609e60c292ea55b387ae8/urllib3-1.26.15-py2.py3-none-any.whl (140 kB) |████████████████████████████████| 140 kB 6.4 MB/s Collecting certifi>=2017.4.17 Downloading https://pypi.tuna.tsinghua.edu.cn/packages/71/4c/3db2b8021bd6f2f0ceb0e088d6b2d49147671f25832fb17970e9b583d742/certifi-2022.12.7-py3-none-any.whl (155 kB) |████████████████████████████████| 155 kB ... Installing collected packages: urllib3, numpy, idna, charset-normalizer, certifi, six, requests, protobuf, Pillow, paddle-bfloat, opt-einsum, decorator, astor, paddlepaddle Successfully installed Pillow-9.5.0 astor-0.8.1 certifi-2022.12.7 charset-normalizer-3.1.0 decorator-5.1.1 idna-3.4 numpy-1.24.3 opt-einsum-3.3.0 paddle-bfloat-0.1.7 paddlepaddle-2.4.2 protobuf-3.20.0 requests-2.29.0 six-1.16.0 urllib3-1.26.15 WARNING: You are using pip version 21.1.1; however, version 23.1.2 is available. You should consider upgrading via the 'D:\Program Files\Python38\python.exe -m pip install --upgrade pip' command. D:\OpenSource\PaddlePaddle>
验证安装
安装完成后您可以使用 python
进入 python 解释器,输入import paddle
,再输入 paddle.utils.run_check()
如果出现PaddlePaddle is installed successfully!
,说明您已成功安装。
D:\OpenSource\PaddlePaddle>python Python 3.8.10 (tags/v3.8.10:3d8993a, May 3 2021, 11:48:03) [MSC v.1928 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import paddle >>> paddle.utils.run_check() Running verify PaddlePaddle program ... PaddlePaddle works well on 1 CPU. D:\Program Files\Python38\lib\site-packages\paddle\fluid\executor.py:1583: UserWarning: Standalone executor is not used for data parallel warnings.warn( W0427 15:23:00.934442 62256 fuse_all_reduce_op_pass.cc:79] Find all_reduce operators: 2. To make the speed faster, some all_reduce ops are fused during training, after fusion, the number of all_reduce ops is 2. PaddlePaddle works well on 2 CPUs. PaddlePaddle is installed successfully! Let's start deep learning with PaddlePaddle now. >>>
如何卸载
CPU 版本的 PaddlePaddle: python -m pip uninstall paddlepaddle
GPU 版本的 PaddlePaddle: python -m pip uninstall paddlepaddle-gpu
PyCharm 中可查看,已安装的包