基础环境: Win10系统 + Python3.6环境 + Visual Studio Code编辑器html
编程环境: miniconda环境 + conemu仿真器 + jupyter解释器python
为何用Python虚拟环境git
实际工做中,咱们接触的 Python 版本和相关的 web 框架版本每每是不同的,好比有的组合多是 python2 + Django1.8,有的多是 python3.6 + Django1.12,两个还好办,我在电脑上安装两个版本的 python 不就行了?github
可是,若是有五六七八个项目,须要五六七八套 python 环境呢?这就轮到虚拟环境登场了。web
本文使用 windows 十、64位系统,文中使用的软件能支持多个系统,下载时可根据具体状况选择对应的软件包安装。django
Python 3.6.5 is now the latest maintenance release of Python 3.6 and supersedes 3.6.2. Get 3.6.5 here. Python 3.6.2 is the second maintenance release of Python 3.6. The Python 3.6 series contains many new features and optimizations. See the What’s New In Python 3.6 document for more information.编程
打开python官网 https://www.python.org/json
==》Downloads ==》windows ==》python 3.6.5windows
安装好了以后,打开CMD界面【不是Python自带的编辑器】,输入“Python”,若是提示相应的版本号和一些指令【因为以前已经勾选了,按理来讲是ok的,固然也有例外】,说明你的Python就已经安装好了;若是显示的Python不是内部或外部命令,则说明你如今还要手动加一下环境变量。浏览器
计算机==》属性==》高级系统设置==》高级==》环境变量,点开找到,找到path这个系统名,点击编辑,在其末尾添加你的安装路径,好比“D:/python”最后保存就ok了。
Visual Studio Code is a lightweight but powerful source code editor which runs on your desktop and is available for Windows, macOS and Linux. It comes with built-in support for JavaScript, TypeScript and Node.js and has a rich ecosystem of extensions for other languages (such as C++, C#, Java, Python, PHP, Go) and runtimes (such as .NET and Unity). Begin your journey with VS Code with these introductory videos.
打开Visual Studio Code官网
==》Downloads ==》Download Visual Studio Code ==》windows
1)首先须要下载Python的插件:
2)以后选择“文件->首选项->用户设置"打开settings.json这个配置文件。 在”默认配置“中能够找到python.pythonPath这一项,须要在settings.json中修改为本机的python位置。
3)打开Python文件所在的文件夹,就能够进行调试了。
Anaconda 是一个用于科学计算的 Python 发行版,支持 Linux, Mac, Windows, 包含了众多流行的科学计算、数据分析的 Python 包。
Anaconda 安装包能够到 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/ 下载。
Miniconda 是一个 Anaconda 的轻量级替代,默认只包含了 python 和 conda,可是能够经过 pip 和 conda 来安装所须要的包。
Miniconda 安装包能够到 https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/ 下载。
选择windonws版本下载“ Miniconda3-latest-Windows-x86_64.exe”
安装miniconda,默认Next+选择环境变量
1)Anaconda 仓库的镜像
分别运行如下命令添加 Anaconda Python 免费仓库:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
2)miniconda命令 #查看版本 conda info —envs或conda env list
注意,为了不你的网络太慢,请先运行下面命令加速一些 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ conda config --set show_channel_urls yes
安装完整版python2版本的conda conda create -n py2 python=2 anaconda
移除虚拟环境 conda remove --all -n 3todo
建立只有django的python2环境,名字py2-dj,注意,python=2 django是连续参数 conda create python=2 django -n py2-dj
若是不指定python版本,那是不可以滴,会报错 conda create -n env-test Error: too few arguments, must supply command line package specs or --file
因此要至少指定个python版本,能够不带任何库 conda create -n env-test python=3 Fetching package metadata .......
clone环境的2种办法
新建环境pytest2,并进入,加入这里只有个requests (pytest2) D:\pyTools>pip freeze requests==2.14.2 下面把pytest的包安装过来 (pytest2) D:\pyTools>pip freeze requests==2.14.2
(pytest2) D:\pyTools>pip freeze Django==1.10.5 requests==2.14.2
ConEmu是一款免费的DOS系统仿真器,体积小巧,界面清爽,支持多标签操做,兼容dos原有的指令,用来替换掉系统自带的cmd,功能更增强大。
ConEmu安装包能够到 https://conemu.github.io/ 下载。
Windows最好配合Anaconda使用,打开conemu
在settings->Startup>Environment
alias cl=conda env list
alias cc=conda create -n $*
alias coa=activate $*
alias cod=deactivate
alias cr=conda remove --all -n $*
jupyter是啥啊? 这个要从ipython提及,ipython是个交互式的python的解释器,自带颜色,补全还有行号,科学界的不少大牛都用来进行数据分析和图形显示。
官方推荐的安装是这个:http://jupyter.readthedocs.io/en/latest/install.html
Download Anaconda. We recommend downloading Anaconda’s latest Python 3 version (currently Python 3.5). Download Anaconda. We recommend downloading Anaconda’s latest Python 3 version (currently Python 3.5). Install the version of Anaconda, which you downloaded. Install Jupyter using conda from the Terminal (Mac and Linux) or a Command Prompt window (Windows): conda install jupyter Congratulations. You have installed Jupyter Notebook. To run the notebook: jupyter notebook
我们民间能够直接安装 若是已经有python环境:
直接pip install jupyter
若是没有: 就先安装个python环境,而后再装
运行 jupyter notebook
而后就自动打开浏览器中localhost的8888端口,就能够在线写代码啦!不止于python,还有R等...
写代码,写文档(cell类型就分红markdown和code,随便改,因此我这文章都是直接写出来的) 科学运算和画图(numpy, scipy,pandas之类的之前都须要一个个安装啊,如今全齐了)