1.安装anaconda
转自:http://www.jianshu.com/p/2f3be7781451Python易用,但用好却不易,其中比较头疼的就是包管理和Python不同版本的问题,特别是当你使用Windows的时候。为了解决这些问题,有不少发行版的Python,比如WinPython、Anaconda等,这些发行版将python和许多常用的package打包,方便pythoners直接使用,此外,还有virtualenv、pyenv等工具管理虚拟环境。
个人尝试了很多类似的发行版,最终选择了Anaconda,因为其强大而方便的包管理与环境管理的功能。该文主要介绍下Anaconda,对Anaconda的理解,并简要总结下相关的操作。
Anaconda概述
Anaconda是一个用于科学计算的Python发行版,支持 Linux, Mac, Windows系统,提供了包管理与环境管理的功能,可以很方便地解决多版本python并存、切换以及各种第三方包安装问题。Anaconda利用工具/命令
conda
来进行package和environment的管理,并且已经包含了Python和相关的配套工具。这里先解释下conda、anaconda这些概念的差别。
conda
可以理解为一个工具,也是一个可执行命令,其核心功能是包管理与环境管理。包管理与pip的使用类似,环境管理则允许用户方便地安装不同版本的python并可以快速切换。Anaconda则是一个打包的集合,里面预装好了conda、某个版本的python、众多packages、科学计算工具等等,所以也称为Python的一种发行版。其实还有Miniconda,顾名思义,它只包含最基本的内容——python与conda,以及相关的必须依赖项,对于空间要求严格的用户,Miniconda是一种选择。进入下文之前,说明一下conda的设计理念——conda将几乎所有的工具、第三方包都当做package对待,甚至包括python和conda自身!因此,conda打破了包管理与环境管理的约束,能非常方便地安装各种版本python、各种package并方便地切换。
国内镜像地址
https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/
下载对应版本
在安装Anaconda之前,有的已经安装过一个Python版本了,但是又不想删除这个Python版本,该怎么办呢?
详细介绍:https://www.cnblogs.com/yamin/p/7111397.html
前提是安裝了python pip
import是为了验证一下是否安装成功
1.安裝request
Microsoft Windows [版本 10.0.15063]
(c) 2017 Microsoft Corporation。保留所有权利。
C:\Users\dell>pip
Usage:
pip <command> [options]
Commands:
install Install packages.
download Download packages.
uninstall Uninstall packages.
freeze Output installed packages in requirements format.
list List installed packages.
show Show information about installed packages.
check Verify installed packages have compatible dependencies.
search Search PyPI for packages.
wheel Build wheels from your requirements.
hash Compute hashes of package archives.
completion A helper command used for command completion.
help Show help for commands.
General Options:
-h, --help Show help.
--isolated Run pip in an isolated mode, ignoring
environment variables and user configuration.
-v, --verbose Give more output. Option is additive, and can be
used up to 3 times.
-V, --version Show version and exit.
-q, --quiet Give less output. Option is additive, and can be
used up to 3 times (corresponding to WARNING,
ERROR, and CRITICAL logging levels).
--log <path> Path to a verbose appending log.
--proxy <proxy> Specify a proxy in the form
[user:passwd@]proxy.server:port.
--retries <retries> Maximum number of retries each connection should
attempt (default 5 times).
--timeout <sec> Set the socket timeout (default 15 seconds).
--exists-action <action> Default action when a path already exists:
(s)witch, (i)gnore, (w)ipe, (b)ackup, (a)bort.
--trusted-host <hostname> Mark this host as trusted, even though it does
not have valid or any HTTPS.
--cert <path> Path to alternate CA bundle.
--client-cert <path> Path to SSL client certificate, a single file
containing the private key and the certificate
in PEM format.
--cache-dir <dir> Store the cache data in <dir>.
--no-cache-dir Disable the cache.
--disable-pip-version-check
Don't periodically check PyPI to determine
whether a new version of pip is available for
download. Implied with --no-index.
C:\Users\dell>pip3 install request
Collecting request
Downloading request-0.0.13.tar.gz
Collecting get (from request)
Downloading get-0.0.21.tar.gz
Collecting post (from request)
Downloading post-0.0.13.tar.gz
Collecting setupfiles (from request)
Downloading setupfiles-0.0.50.tar.gz
Collecting query_string (from get->request)
Downloading query_string-0.0.12.tar.gz
Collecting public (from query_string->get->request)
Downloading public-0.0.38.tar.gz
Installing collected packages: setupfiles, public, query-string, get, post, request
Running setup.py install for setupfiles ... done
Running setup.py install for public ... done
Running setup.py install for query-string ... done
Running setup.py install for get ... done
Running setup.py install for post ... done
Running setup.py install for request ... done
Successfully installed get-0.0.21 post-0.0.13 public-0.0.38 query-string-0.0.12 request-0.0.13 setupfiles-0.0.50
2.安装
selenium
C:\Users\dell>pip3 install selenium
Collecting selenium
Downloading selenium-3.7.0-py2.py3-none-any.whl (935kB)
100% |████████████████████████████████| 942kB 283kB/s
Installing collected packages: selenium
Successfully installed selenium-3.7.0
C:\Users\dell>python
Python 3.6.3 (v3.6.3:2c5fed8, Oct 3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import selenium
>>>