目录
python本身
就python本身来说,使用python语言编写程序之前需要下载一个python解释器(python.exe),位于你安装python的地方,比如我的
其中Lib目录是python包文件,包含自带的包(如logging)和第三方包(位于site-packages文件夹)
Anaconda:是包管理器和环境管理器。
你可能已经安装了 Python,那么为什么还需要 Anaconda?有以下3个原因:
1)Anaconda 附带了一大批常用数据科学包,它附带了 conda、Python 和 150 多个科学包及其依赖项。因此你可以立即开始处理数据。
2)管理包
Anaconda 是在 conda(一个包管理器和环境管理器)上发展出来的。
在数据分析中,你会用到很多第三方的包,而conda(包管理器)可以很好的帮助你在计算机上安装和管理这些包,包括安装、卸载和更新包。
3)管理环境
为什么需要管理环境呢?比如你在A项目中用了 Python 2,而新的项目B老大要求使用Python 3,而同时安装两个Python版本可能会造成许多混乱和错误。这时候 conda就可以帮助你为不同的项目建立不同的运行环境。
还有很多项目使用的包版本不同,比如不同的pandas版本,不可能同时安装两个 Numpy 版本,你要做的应该是,为每个 Numpy 版本创建一个环境,然后项目的对应环境中工作。这时候conda就可以帮你做到。
官方安装教程:https://docs.anaconda.com/anaconda/install/windows/ (特别注意:步骤8[建议不勾选]和9[建议勾选])
注意:Anaconda安装包不要使用默认的官网,速度太慢,可以使用清华的镜像:https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
通过Anaconda Navigator 或者 conda确认Anaconda安装成功:
a.能正确打开Anaconda Navigator
b.conda
After opening Anaconda Prompt or the terminal, choose any of the following methods to verify:
- Enter
conda list
. If Anaconda is installed and working, this will display a list of installed packages and their versions. - Enter the command
python
. This command runs the Python shell. If Anaconda is installed and working, the version information it displays when it starts up will include “Anaconda”. To exit the Python shell, enter the commandquit()
. - Open Anaconda Navigator with the command
anaconda-navigator
. If Anaconda is installed properly, Anaconda Navigator will open.
使用图形化界面:
不使用图形化界面:
以下是示例:注意要使用 activate 环境名 切换到要安装的环境,默认是base,之后进入到如(D:softAnaconda3envsmysiteScripts)目录执行pip install或者conda install安装第三方包。(网上大多数说要进入Scripts目录,其实以下例子中我并没有进入到Scripts目录执行pip或者conda,暂时没有发现问题,此处暂时记录一下)
(base) C:Usersiphauser>d: (base) D:>cd soft (base) D:soft>dir 驱动器 D 中的卷是 新加卷 卷的序列号是 960E-961E D:soft 的目录 2019/11/14 15:23 <DIR> . 2019/11/14 15:23 <DIR> .. 2019/07/03 11:54 <DIR> 360 2019/06/24 10:46 <DIR> 49chrome 2019/11/15 15:53 <DIR> Anaconda3 2019/07/10 10:21 <DIR> apache-jmeter-5.1.1 2019/07/09 16:19 59,684,716 apache-jmeter-5.1.1.zip 2019/11/14 09:39 <DIR> BaiduNetdisk 2019/03/15 20:49 <DIR> Bypass 2019/09/17 15:24 3,731,017 Bypass_1.13.64.zip 2019/07/29 10:01 <DIR> DingDing 2019/07/15 09:21 <DIR> DriverGenius 2019/09/27 18:10 <DIR> eclipse 2019/11/13 16:19 <DIR> Evernote 2019/07/16 10:18 <DIR> extension_3_0 2019/07/13 13:09 <DIR> extension_4_6 2019/08/20 13:55 <DIR> Fiddler 2019/08/20 18:24 <DIR> Firefox 2019/06/24 16:34 <DIR> foxit 2019/06/24 16:11 <DIR> Foxmail 2019/11/06 10:59 <DIR> iTunes 2019/07/15 13:57 <DIR> java 2019/08/02 17:59 4,396,641 luyten-0.5.4.exe 2019/06/25 10:01 <DIR> Navicat 2019/08/02 11:00 <DIR> nodejs 2019/07/03 16:32 <DIR> Notepad++ 2019/11/04 16:53 <DIR> PortableGit 2015/09/30 04:41 29,163,040 PortableGit-2.6.0-32-bit.7z.exe 2019/06/24 11:13 29,121,569 PortableGit-2.6.0-32-bit.zip 2019/01/17 13:19 <DIR> py12306-master 2019/09/17 15:29 2,690,909 py12306master.zip 2019/06/24 11:31 <DIR> PyCharm 2019/11/08 15:17 <DIR> PyCharmPro 2019/09/03 18:53 <DIR> python36 2019/07/23 19:36 <DIR> redisclient 2018/11/12 16:02 51,187,435 redisclient-win32.x86.2.0.exe 2019/06/24 10:48 <DIR> SecureCRT 2019/09/09 16:28 <DIR> sun 2019/07/03 16:34 <DIR> Thunder 2019/11/13 11:05 <DIR> tim 2019/09/19 10:10 <DIR> VirtualMachines 2019/09/18 15:49 <DIR> VMware 2019/10/28 09:40 <DIR> WeChat 2019/07/11 09:34 <DIR> WeChat Files 2019/07/15 14:10 <DIR> WinRAR 2019/09/24 10:24 <DIR> XMind 7 个文件 179,975,327 字节 39 个目录 104,206,663,680 可用字节 (base) D:soft>cd Anaconda3 (base) D:softAnaconda3>CD envs (base) D:softAnaconda3envs>DIR 驱动器 D 中的卷是 新加卷 卷的序列号是 960E-961E D:softAnaconda3envs 的目录 2019/11/15 17:13 <DIR> . 2019/11/15 17:13 <DIR> .. 2019/11/15 15:56 <DIR> first_demo 2019/11/15 16:38 <DIR> mysite 2019/11/15 16:30 <DIR> mysite_env 0 个文件 0 字节 5 个目录 104,206,663,680 可用字节 (base) D:softAnaconda3envs>activate mysite (mysite) D:softAnaconda3envs>conda install requests Collecting package metadata (repodata.json): done Solving environment: done ## Package Plan ## environment location: D:softAnaconda3envsmysite added / updated specs: - requests The following packages will be downloaded: package | build ---------------------------|----------------- asn1crypto-1.2.0 | py36_0 162 KB cffi-1.13.1 | py36h7a1dbc1_0 226 KB chardet-3.0.4 | py36_1003 215 KB idna-2.8 | py36_0 134 KB pycparser-2.19 | py36_0 174 KB pyopenssl-19.0.0 | py36_0 82 KB pysocks-1.7.1 | py36_0 31 KB requests-2.22.0 | py36_0 90 KB six-1.13.0 | py36_0 27 KB urllib3-1.24.2 | py36_0 153 KB win_inet_pton-1.1.0 | py36_0 9 KB ------------------------------------------------------------ Total: 1.3 MB The following NEW packages will be INSTALLED: asn1crypto pkgs/main/win-64::asn1crypto-1.2.0-py36_0 ca-certificates pkgs/main/win-64::ca-certificates-2019.10.16-0 cffi pkgs/main/win-64::cffi-1.13.1-py36h7a1dbc1_0 chardet pkgs/main/win-64::chardet-3.0.4-py36_1003 cryptography pkgs/main/win-64::cryptography-2.8-py36h7a1dbc1_0 idna pkgs/main/win-64::idna-2.8-py36_0 openssl pkgs/main/win-64::openssl-1.1.1d-he774522_3 pycparser pkgs/main/win-64::pycparser-2.19-py36_0 pyopenssl pkgs/main/win-64::pyopenssl-19.0.0-py36_0 pysocks pkgs/main/win-64::pysocks-1.7.1-py36_0 requests pkgs/main/win-64::requests-2.22.0-py36_0 six pkgs/main/win-64::six-1.13.0-py36_0 urllib3 pkgs/main/win-64::urllib3-1.24.2-py36_0 win_inet_pton pkgs/main/win-64::win_inet_pton-1.1.0-py36_0 Proceed ([y]/n)? y Downloading and Extracting Packages chardet-3.0.4 | 215 KB | ############################################################################ | 100% pysocks-1.7.1 | 31 KB | ############################################################################ | 100% asn1crypto-1.2.0 | 162 KB | ############################################################################ | 100% win_inet_pton-1.1.0 | 9 KB | ############################################################################ | 100% six-1.13.0 | 27 KB | ############################################################################ | 100% urllib3-1.24.2 | 153 KB | ############################################################################ | 100% pyopenssl-19.0.0 | 82 KB | ############################################################################ | 100% requests-2.22.0 | 90 KB | ############################################################################ | 100% idna-2.8 | 134 KB | ############################################################################ | 100% cffi-1.13.1 | 226 KB | ############################################################################ | 100% pycparser-2.19 | 174 KB | ############################################################################ | 100% Preparing transaction: done Verifying transaction: done Executing transaction: done (mysite) D:softAnaconda3envs>pip list Package Version ------------- ------------------- asn1crypto 1.2.0 certifi 2019.9.11 cffi 1.13.1 chardet 3.0.4 cryptography 2.8 Django 2.2.5 idna 2.8 pip 19.3.1 pycparser 2.19 pyOpenSSL 19.0.0 PySocks 1.7.1 pytz 2019.3 requests 2.22.0 setuptools 41.6.0.post20191030 six 1.13.0 sqlparse 0.3.0 urllib3 1.24.2 wheel 0.33.6 win-inet-pton 1.1.0 wincertstore 0.2 (mysite) D:softAnaconda3envs>pip install pymysql Collecting pymysql Downloading https://files.pythonhosted.org/packages/ed/39/15045ae46f2a123019aa968dfcba0396c161c20f855f11dea6796bcaae95/PyMySQL-0.9.3-py2.py3-none-any.whl (47kB) |████████████████████████████████| 51kB 148kB/s Installing collected packages: pymysql Successfully installed pymysql-0.9.3 (mysite) D:softAnaconda3envs>pip list Package Version ------------- ------------------- asn1crypto 1.2.0 certifi 2019.9.11 cffi 1.13.1 chardet 3.0.4 cryptography 2.8 Django 2.2.5 idna 2.8 pip 19.3.1 pycparser 2.19 PyMySQL 0.9.3 pyOpenSSL 19.0.0 PySocks 1.7.1 pytz 2019.3 requests 2.22.0 setuptools 41.6.0.post20191030 six 1.13.0 sqlparse 0.3.0 urllib3 1.24.2 wheel 0.33.6 win-inet-pton 1.1.0 wincertstore 0.2 (mysite) D:softAnaconda3envs>