机器学习与深度学习开发环境Python3.6(win10-64)全新自主安装过程

Python工作环境有多种安装方法,比如Anaconda,但是本文是以自主方式安装、搭建机器学习与深度学习Python开发环境,以此方式方便深入了解、掌握各种工具包、第三方应用的使用管理,为了避免“重复造轮子”,通过本文总结早期环境部署及开发中经验。

安装python的方法有很多种,数据分析方面比较常用Anaconda。Anaconda是一个开源的Python发行版本,其包含了conda、Python等多个科学包及其依赖项,也可以使用Miniconda这个较小的发行版,仅包含conda和 Python。Anaconda可以管理包,就是能够安装、更新、移除工具包,比如Numpy、Scipy、pandas、Scikit-learn等数据分析中常用的包;也可以管理环境,能够创建、访问、共享、移除环境,用于隔离不同项目所需要的不同版本的工具包,所以,我们可以建立 Python2 和 Python3 两个环境,来分别运行不同版本的 Python 代码。

1 Python安装

我近期使用Python 3.6版本(未换最新版本),由于安装比较简单,此处略去python安装过程。其中,安装路径为D:\Python\Python36。(网站https://www.python.org/downloads/windows,下载python3.6.7-Win10-64版本请点击
在这里插入图片描述

安装完成后,需要配置环境变量,如下图所示。在这里插入图片描述

2 Python扩展包安装过程

2.1 图像处理

第一步,安装绘图包
D:>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple D:\Python\pythonlib\matplotlib-3.0.3-cp36-cp36m-win_amd64.whl
其中:
Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple 为指定国内pypi安装包源,存在国外链接不上的问题。
Processing d:\python\pythonlib\matplotlib-3.0.3-cp36-cp36m-win_amd64.whl 为windows环境下安装包,来自https://www.lfd.uci.edu/~gohlke/pythonlibs/

安装结果

Installing collected packages: six, cycler, kiwisolver, numpy, pyparsing, python-dateutil, matplotlib
Successfully installed cycler-0.10.0 kiwisolver-1.2.0 matplotlib-3.0.3 numpy-1.19.0 pyparsing-2.4.7 python-dateutil-2.8.1 six-1.15.0

第二步 安装图像处理CV和image
D:\Python>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple opencv-python
D:\Python>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple D:\Python\pythonlib\scikit_image-0.17.2-cp36-cp36m-win_amd64.whl
Installing collected packages: pillow, tifffile, PyWavelets, imageio, networkx, scikit-image
Successfully installed PyWavelets-1.1.1 imageio-2.9.0 networkx-2.4 pillow-7.2.0 scikit-image-0.17.2 tifffile-2020.7.4

2.2 数据分析

第三步,安装numpy
由于tensorflow版本的要求,以及SciPy依赖于numpy+mkl,安装scipy前需要先安装好numpy+mkl,这样需要先卸载已经自动携带安装的numpy。
D:\Python>pip uninstall numpy
Uninstalling numpy-1.19.0:

D:\Python>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple D:\Python\pythonlib\numpy-1.16.6+mkl-cp36-cp36m-win_amd64.whl

第四步,安装科学计算包SciPy
数学、科学和工程相关功能库,类似Matlab,可用于如傅里叶变换、信号处理、线性代数类、图像处理类、稀疏图压缩类、稀疏运算类、优化算法类等应用
D:\Python>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple D:\Python\pythonlib\scipy-1.0.1-cp36-none-win_amd64.whl

第五步,安装Pandas
Pandas是Python数据分析高层次应用库,提供管理简单易用的数据结构和数据分析工具。

D:\Python>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pandas
Installing collected packages: pytz, pandas
Successfully installed pandas-1.0.5 pytz-2020.1

2.3 机器学习

第六步,安装sklearn
Scikit-learn项目最早由数据科学家 David Cournapeau 在 2007 年发起,需要NumPy和SciPy等其他包的支持,是Python语言中专门针对机器学习应用而发展起来的一款开源框架。

在Windows环境中,sklearn 需要在安装 numpy+mkl 和scipy 之后才可以安装,安装过程如下。首先,下载Python scikit-learn,Windows版下载网站地址为:https://www.lfd.uci.edu/~gohlke/pythonlibs/

D:\Python>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple D:\Python\pythonlib\scikit_learn-0.19.1-cp36-cp36m-win_amd64.whl

D:\Python>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple D:\Python\pythonlib\sklearn_contrib_py_earth-0.1.0-cp36-cp36m-win_amd64.whl

第七步,安装XGBoot
XGBoost是陈天奇等人开发的一个开源机器学习项目,高效地实现了GBDT算法并进行了算法和工程上的许多改进,被广泛应用在Kaggle竞赛及其他许多机器学习竞赛中并取得了不错的成绩。

说到XGBoost,不得不提GBDT(Gradient Boosting Decision Tree)。因为XGBoost本质上还是一个GBDT,但是力争把速度和效率发挥到极致,所以叫X (Extreme) GBoosted。包括前面说过,两者都是boosting方法。

D:\Python>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple D:\Python\pythonlib\xgboost-0.72-cp36-cp36m-win_amd64.whl

2.4 深度学习

第八步,tensorflow安装CPU 1.13.2版本(需要和Tensorbord配套)
D:\Python>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple tensorflow==1.13.2
Successfully installed absl-py-0.9.0 astor-0.8.1 gast-0.3.3 grpcio-1.30.0 h5py-2.10.0 importlib-metadata-1.7.0 keras-applications-1.0.8 keras-preprocessing-1.1.2 markdown-3.2.2 mock-4.0.2 protobuf-3.12.2 tensorboard-1.13.1 tensorflow-1.13.2 tensorflow-estimator-1.13.0 termcolor-1.1.0 wheel-0.34.2 zipp-3.1.0

第九步,安装开发框架keras
D:\Python>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple keras
Installing collected packages: pyyaml, keras
Successfully installed keras-2.4.3 pyyaml-5.3.1

2.5 Web服务(Web Service)

第十步,安装web服务flask
D:\Python>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple flask
Installing collected packages: Werkzeug, click, itsdangerous, MarkupSafe, Jinja2, flask
Successfully installed Jinja2-2.11.2 MarkupSafe-1.1.1 Werkzeug-1.0.1 click-7.1.2 flask-1.1.2 itsdangerous-1.1.0

2.6 数据库驱动

第十一步,安装mongodb数据库驱动
MongoDB是一个基于分布式文件存储的数据库,由C++语言编写。旨在为WEB应用提供可扩展的高性能数据存储解决方案。
D:\Python>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple pymongo

2.7 在线开发编辑工具

第十二步,安装在线Python开发编辑工具
D:\Python>pip install -i https://pypi.tuna.tsinghua.edu.cn/simple jupyter

Successfully built pandocfilters pyrsistent
Installing collected packages: pyzmq, decorator, ipython-genutils, traitlets, pywin32, jupyter-core,

设置默认工作目录:
D:\Python>jupyter-notebook --generate-config
Writing default config to: C:\Users\xiaoyw.jupyter\jupyter_notebook_config.py

修改配置文件:用文本编辑器,打开“C:\Users\xiaoyw.jupyter\jupyter_notebook_config.py”文件,查找“notebook_dir”参数
c.NotebookApp.notebook_dir = ‘D:\01Study\jupyter_notebook’

在桌面创建快捷方式:D:\Python\Python36\Scripts\jupyter-notebook.exe

如有遗漏,欢迎帮助补充。

参考:
1.使用Python Matplotlib绘图并输出图像到文件中的实践,涉及到的包有:six、cycler、pyparsing、python-dateutil 、kiwisolver、numpy、pytz、matplotlib。 CSDN博客 肖永威 2018.4.14
2.Python科学计算初探——余弦相似度,涉及到的包有:numpy、 scipy。 CSDN博客 肖永威 2018.4.25
3.Python sklearn决策树算法实践,涉及到的包有:scikit-learn。 CSDN博客 肖永威 2018.4.28
4.使用Python科学计算包搭建CNN算法实践(1),涉及到的包有:scikit_image、decorator、networkx、Pillow、PyWavelets。 CSDN博客 肖永威 2018.5.9
5.XGBoost算法应用入门学习实践,涉及到的包有:xgboost。 CSDN博客 肖永威 2018.6.25
6.Python基于Flask开发Restful API实践,涉及到的包有:Jinja、 MarkupSafe、 Werkzeug、 click、 flask、 itsdangerous。 CSDN博客 肖永威 2018.7.12
7.Python开发中使用Mongo DB入门实践,涉及到的包有:pymongo。 CSDN博客 肖永威 2018.7.14
8.Python入门学习(一),安装Eclipse开发环境 CSDN博客 肖永威 2017.12
9.Windows10(64bit)环境下Python3 + Tensorflow安装 CSDN博客 肖永威 2018.8.21
10.使用Python开发工具Jupyter Notebook学习Tensorflow入门及Tensorboard实践 CSDN博客 肖永威 2019.1.17
11.学习基于Keras框架的ResNet网络及实践笔记 CSDN博客 肖永威 2019.6.7

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

肖永威

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值