python 一些包的安裝

来源:互联网 发布:cad 布局 知乎 编辑:程序博客网 时间:2024/05/29 14:30

1.安装anaconda

Python易用,但用好却不易,其中比较头疼的就是包管理和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并方便地切换。

转自:http://www.jianshu.com/p/2f3be7781451

国内镜像地址

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>pipUsage:  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 requestCollecting request  Downloading request-0.0.13.tar.gzCollecting get (from request)  Downloading get-0.0.21.tar.gzCollecting post (from request)  Downloading post-0.0.13.tar.gzCollecting setupfiles (from request)  Downloading setupfiles-0.0.50.tar.gzCollecting query_string (from get->request)  Downloading query_string-0.0.12.tar.gzCollecting public (from query_string->get->request)  Downloading public-0.0.38.tar.gzInstalling 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 ... doneSuccessfully 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 seleniumCollecting selenium  Downloading selenium-3.7.0-py2.py3-none-any.whl (935kB)    100% |████████████████████████████████| 942kB 283kB/sInstalling collected packages: seleniumSuccessfully installed selenium-3.7.0C:\Users\dell>pythonPython 3.6.3 (v3.6.3:2c5fed8, Oct  3 2017, 18:11:49) [MSC v.1900 64 bit (AMD64)] on win32Type "help", "copyright", "credits" or "license" for more information.>>> import  selenium>>>



原创粉丝点击