目录
禁止转载,侵权必究!
前言
机器学习领域主流的编程语言是python,想深入这个领域,基础的python知识必不可少。当然,编程思想是相同的,我相信大家在这部分教程的学习中会感到相当轻松。
一、Mac环境安装
前往官网下载Anaconda Navigator,安装完成后在你的.bash_profile中会发现以下配置

1.创建Python运行环境
因为python可以从事很多类型的开发,比如爬虫,网页、机器学习等等,我们应该首先为自己创建一个env,避免被软件版本问题干扰。

2. 通过pip安装python软件包
比如Mac版本的PaddlePaddle可以用下面命令安装:
# 其中-i表示安装源
python -m pip install paddlepaddle==2.2.2 -i https://mirror.baidu.com/pypi/simple
3.启动vscode
在Anaconda Navigator内部启动vscode

4.安装vscode中的python环境
安装python插件

1.在vscode的设置中配置python版本。指向anaconda的python。(在你的env中打开命令行,执行which python)。配置好之后左下角会显示python版本号以及anaconda中的env名字(如上图)。
python.pythonPath
2.设置vscode的终端窗口的python版本,在vscode的终端窗口中执行命令which python,当它指向我们自己env的python表示配置正确(如上图)。如果不行,请重启vscode再试。
// 配置为false
terminal.integrated.inheritEnv
配置完毕。
二、Windows环境安装
1. 下载&安装Anaconda Navigator
因为软件更新很快,为了使用python3.7(避免兼容性问题),可以在achieve中选择需要的版本。比如:Anaconda3-2020.02-Windows-x86_64
2. 安装VSCode
安装完成后,在ANACONDA中刷新,可以看到已经被加入列表中了。

3.创建运行环境
请参考附录
3.通过pip安装软件
# 以paddlepaddle安装为例
# 这里指定了1.8.x版本,避免兼容问题
pip install paddlepaddle==1.8.5 -i https://mirror.baidu.com/pypi/simple
三、 Win Server安装
需要增加以下截图中的两个步骤:


安装完毕后重启服务器即可。
附录:
1. 加快软件启动速度(以Mac为例)
修改 /etc/hosts 增加下面一行,加快Anaconda Navigator的启动速度。
127.0.0.1 api.anaconda.org
2. 配置pip国内加速镜像源(以windows为例)


pip.ini的内容
[global]
timeout = 6000
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com
执行下列命令检查pip镜像是否配置成功
3. conda常用命令
1.列举所有的环境
conda env list
2.激活环境
activate xxx
ANACONDA中的VSCode无法正确应用env,可以用这个命令!
3. 列举当前环境下安装的包
conda list xxpkg
(paddle-gpu) C:\Users\ouyang>pip config list
global.index-url='http://mirrors.aliyun.com/pypi/simple/'
global.timeout='6000'
global.trusted-host='mirrors.aliyun.com'