总目录:https://www.jianshu.com/p/e406a9bc93a9
Python - 子目录:https://www.jianshu.com/p/50b432cb9460
关于模块怎么使用我们已经说得很清楚了,
form -- import 语句
import 语句
第三方模块
我们来简单说说安装第三方模块:
pip 安装
conda 安装 #我使用的就是anaconda
pip
安装一个模块:
pip install numpy
如果报错的话,可以先更新一下pip
pip install --upgrade pip
如果还是不行,我们来使用:
python -m pip install numpy
通过调用 Python的 -m参数调用pip脚本来安装。
注: -m参数的解释
run library module as a script (terminates option list)
将库模块作为脚本运行(终止选项列表)
其他一些pip的命令
在命令行查看pip的帮助手册。
pip --help
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.检查包的依赖关系是否完整
config Manage local and global configuration.管理配置
search Search PyPI for packages.搜索包
hash Compute hashes of package archives.计算包的hash值
completion A helper command used for command completion.
help Show help for commands.
之后我们再说一些wheel的安装方式,有一些第三方包没有在pypi那里开源,是一些私有包,我们就需要wheel来安装。
首先要安装wheel
pip install wheel
之后直接
pip install whl文件路径
whl下载地址:https://www.lfd.uci.edu/~gohlke/pythonlibs/
conda
我们先下载安装一个anaconda
然后配置环境变量。
命令行这样就行了。
之后conda --help
conda --help
usage: conda [-h] [-V] command ...
conda is a tool for managing and deploying applications, environments and packages.
Options:
positional arguments:
command
info Display information about current conda install.
help Displays a list of available conda commands and their help
strings.
list List linked packages in a conda environment. 查看
search Search for packages and display their information. 搜索
create Create a new conda environment from a list of specified
packages.
install Installs a list of packages into a specified conda environment.安装
update Updates conda packages to the latest compatible version. 更新
upgrade Alias for conda update. See conda update --help.
remove Remove a list of packages from a specified conda environment. 卸载
uninstall Alias for conda remove. See conda remove --help.
config Modify configuration values in .
clean Remove unused packages and caches.
package Low-level conda package utility. (EXPERIMENTAL)
optional arguments:
-h, --help Show this help message and exit.
-V, --version Show the conda version number and exit.
other commands, such as "conda build", are available when additional conda
packages (e.g. conda-build) are installed
anaconda的默认安装库已经包含了很多开发经常用到的库。
语法和pip大致相同。