再次认识pip与pip3 in Python

  • pip

    pip is a package manager for Python packages, or modules if you like .

    From PyPA, pip is already installed if you are using Python 2>2.7.9 or Python 3>3.4 downloaded from python.org or if you are working in a Vitual Environment created by virtualenv or pyvenv.

    What is a Package and Module?

    A package contains all the files you need for a module.

    Modules are Python code libraries you can include in your project.

  • pip3

    From [Do we need pip] and [pip3]?,

    There is no program called pip3.

    pip3 is just a synonym of pip, 就像某个软件(比如typora)针对win10win8的区别。

    pip is a Python package that can be executed as

    pythonN.M -m pip 
    

    这种方式是最好的pip执行方案,不用解决pip版本,版本在pythonN.M中指明了。

  • soft link

    ls -l `which pip`
    ls -l `which pip3`
    
  • 作用机理

    When you issue a command like pip install package:

    1. it checks an online repository and downloads the package(which may contain multiple modules)
    2. then puts the modules in a designated place
    3. updates a local index to record where they can be found
  • 必知必会

    all commands could be find Reference Guide.

    • pip install -r requirements.txt

      “Requirements files” are files containing a list of items to be installed using pip install .

      Logically, a Requirements file is just a list of pip install argument placed in a file.

      Requirement files are used to hold the result from pip freeze for the purpose of archieving repeatable installations.

      pip freeze > requirements.txt

    • pip install package.whl

      pip prefers wheels where they are available.

      to build wheels for your requirements through pip wheel, you need wheel library.

    • pip uninstall package

    • pip list

      pip list --outdated

    • pip show package

    • pip search "package"

      search PyPI for packages

  • 总结

    pythonN.M -m pip 是最佳时间方案。

  • References

  1. pip or pip3 to install packages for Python 3?
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值