conda环境管理:
# 创建一个名为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包管理
# 安装xxxx
conda install xxxx
# 查看当前环境下已安装的包
conda list
# 查看某个指定环境的已安装包
conda list -n python36
# 查找package信息
conda search numpy
# 安装package
conda install -n python34 numpy # 如果不用-n指定环境名称,则被安装在当前活跃环境 也可以通过-c指定通过某个channel安装
Conda 更新
# 更新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使用
# 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参数解释
$ 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