2.5.1Python-模块的使用(pip和conda)

总目录:https://blog.csdn.net/qq_41106844/article/details/105553392

Python - 子目录:https://blog.csdn.net/qq_41106844/article/details/105553333

 

 

关于模块怎么使用我们已经说得很清楚了,

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

https://www.anaconda.com/

然后配置环境变量。

命令行这样就行了。

 
20155953-3f9d069186a3bbb6.png
 

之后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大致相同。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

寒 暄

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值