conda,pip常见命令归纳
为了不要天天去找别人的博客查看命令,我想写篇博客总结conda的常见命令:
conda命令:
1.查看conda 版本
conda -V # conda --version
2.更新升级conda
conda update conda
conda update -n base -c defaults conda
3.虚拟环境
创建python环境
conda create --name <env_name> <package_names>
切换python环境
conda activate env_name
退出当前的python环境
conda deactivate
显示安装过的所有虚拟环境
conda info --envs
或
conda info -e
或
conda env list
复制环境
conda create --name new_env_name --clone copied_env_name
删除环境
conda remove --name env_name --all
4.包管理
安装一个或多个包
conda install package
指定环境安装包
conda install --name 环境名 要安装的包名
要指定版本时
conda install --name 要安装的包名=版本
更新包
conda update package #加上 --all 表示更新所有包
查看已经安装的包
conda list
conda list -n xxx #指定查看xxx虚拟环境下安装的package
删除包
conda remove package#多个包命则删除多个包
5.清理conda
第一步:通过conda clean -p来删除一些没用的包,这个命令会检查哪些包没有在包缓存中被硬依赖到其他地方,并删除它们。第二步:通过conda clean -t可以将conda下载下来的tar包删除。
conda clean -p #删除没有用的包
conda clean -t #删除tar包
conda clean -y -all #删除所有的安装包及cache
6.更新python
conda update python
7.换清华源国科大源
我测试过的这是最好的组合
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
当然也可以编辑
vim ~/.condarc
把上面的网址复制进去
删除 -default行
pip命令汇总
1检查哪些包需要更新
pip list --outdated
2升级包
pip install --upgrade package_name
3.使用手册
(base) linhu@linhu-Lenovo-Legion-Y7000:~$ pip -h //查看帮助手册
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.
debug Show information useful for debugging.
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:p
ort.
--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 or host:port
pair 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
--no-python-version-warning
Silence deprecation warnings
for upcoming unsupported
Pythons.