使用conda 與pip命令管理Python庫

conda環境管理:python

# 建立一個名爲python36的環境,指定Python版本是3.6
conda create --name python36 python=3.6

# 激活某個環境
activate python36 # for Windows
source activate python36 # for Linux & Mac

deactivate python36 # for Windows
source deactivate python36 # for Linux & Mac

# 刪除一個已有的環境
conda remove --name python36 --all

conda包管理app

# 安裝xxxx
conda install xxxx

# 查看當前環境下已安裝的包
conda list

# 查看某個指定環境的已安裝包
conda list -n python36

# 查找package信息
conda search numpy

# 安裝package
conda install -n python34 numpy # 若是不用-n指定環境名稱,則被安裝在當前活躍環境 也能夠經過-c指定經過某個channel安裝

Conda 更新less

# 更新package
conda update -n python34 numpy

# 刪除package
conda remove -n python34 numpy

# 更新conda,保持conda最新
conda update -n base conda

# 更新anaconda
conda update anaconda

# 更新python
conda update python

 

pip使用socket

# pip安裝包
$ pip install SomePackage
[...]
  Successfully installed SomePackage

# pip查看已安裝的包
$ pip show --files SomePackage
  Name: SomePackage
  Version: 1.0
  Location: /my/env/lib/pythonx.x/site-packages
  Files:
   ../somepackage/__init__.py
   [...]

# pip檢查哪些包須要更新
$ pip list --outdated
  SomePackage (Current: 1.0 Latest: 2.0)

# pip升級包
$ pip install --upgrade SomePackage
  [...]
  Found existing installation: SomePackage 1.0
  Uninstalling SomePackage:
    Successfully uninstalled SomePackage
  Running setup.py install for SomePackage
  Successfully installed SomePackage

# pip卸載
$ pip uninstall SomePackage
  Uninstalling SomePackage:
    /my/env/lib/pythonx.x/site-packages/somepackage
  Proceed (y/n)? y
  Successfully uninstalled SomePackage

pip參數解釋ui

$ 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.
  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.
  --no-color                  Suppress colored output
相關文章
相關標籤/搜索