pythonlibrary安装教程_第二章 Python中第三方的库(library)的安装方法

本文介绍了如何在Python环境中管理包,包括从.tar.gz和.zip文件手动安装,以及使用pip自动化安装和升级过程。强调了pip作为自动化工具在处理依赖关系上的便利性,并提供了安装pip的方法以及使用pip进行安装、升级、卸载和查询包的命令。

在pipy,github等网站,下载源码,往往都是.tar.gz,.zip的压缩包,解压后,打开windows的cmd,切换到对应目录,运行:

setup.py install

即可安装。

建议提前阅读一下README.md,大部分python库都有依赖其他的包,需要先安装依赖的库。

方法2:利用第三方安装工具(如pip,easy_install,distribute等)去自动化安装

第三方工具pip,easy_install,distribute等,可以自动帮你下载源码,并安装。

很多时候,要安装的包还要依赖一些其他的包,而这类工具会动帮你下载并安装所缺少的那些包,所以相对来说,就省去你的麻烦。(目前python 3的安装包内置pip工具,可直接使用)

检查pip是否可以使用:

144163027_1_2018091302460267

如果安装的python没有带Pip,可用下面的方式安装:

Pip的安装可以通过源代码包,easy_install或者脚本。

下面介绍一下各种安装方法:

源代码方式:

$ wget http://pypi.python.org/packages/source/p/pip/pip-0.7.2.tar.gz (替换为最新的包)$ tar xzf pip-0.7.2.tar.gz$ cd pip-0.7.2$ python setup.py install

$ curl -0 https://raw.github.com/pypa/pip/master/contrib/get-pip.py

$ sudo python get-pip.py

接下来, 看一下Pip的使用

安装package

$ pip install Markdown (pip install --upgrade Markdown)

列出安装的packages

$ pip freeze

安装特定版本的package

通过使用==, >=, <=, >,

$ pip install 'Markdown<2.0'

$ pip install 'Markdown>2.0,<2.0.3'

升级包

升级包到当前最新的版本,可以使用-U 或者 --upgrade

$ pip install -U Markdown

卸载包

$ pip uninstall Markdown

查询包

pip search "Markdown"

安装后的包在pythonLibsite-packages 目录下。

使用代理

144163027_2_20180913024602254

Python3.6标准 It contains data types that would normally be considered part of the “core” of a language, such as numbers and lists. For these types, the Python language core defines the form of literals and places some constraints on their semantics, but does not fully define the semantics. The library also contains built-in functions and exceptions — objects that can be used by all Python code without the need of an import statement. Some of these are defined by the core language, but many are not essential for the core semantics and are only described here. The bulk of the library, however, consists of a collection of modules. There are many ways to dissect this collection. Some modules are written in C and built in to the Python interpreter; others are written in Python and imported in source form. Some modules provide interfaces that are highly specific to Python, like printing a stack trace; some provide interfaces that are specific to particular operating systems, such as access to specific hardware; others provide interfaces that are specific to a particular application domain, like the World Wide Web. Some modules are available in all versions and ports of Python; others are only available when the underlying system supports or requires them; yet others are available only when a particular configuration option was chosen at the time when Python was compiled and installed. This manual is organized “from the inside out:” it first describes the built-in functions, data types and exceptions, and finally the modules, grouped in chapters of related modules. This means that if you start reading this manual from the start, and skip to the next chapter when you get bored, you will get a reasonable overview of the available modules and application areas that are supported by the Python library. Of course, you don’t have to read it like a novel — you can also browse the table of contents (in front of the manual), or look for a specific function, module or term in the index (in the back). And finally, if you enjoy learning about random subjects, you choose a random page number (see module random) and read a section or two. Regardless of the order in which you read the sections of this manual, it helps to start with chapter Built-in Functions, as the remainder of the manual assumes familiarity with this material.
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值