赞
踩
pip简介:一种用于管理Python包的工具。
在virtualenv或conda create的虚拟环境下直接使用pip,就可以将包安装在指定环境下。如果不在Python环境下,需要在命令行前面加上 python -m
(如果Python解释器不在默认路径,就用完整的解释器路径,举例:/home/myusername/anaconda3/envs/envname/bin/python -m
)
pip install
pip install numpy
(一般建议参考包官网及pypi官网,了解具体的包安装方式)pip install numpy
pip install scipy
官网安装教程:SciPy - Installationpip install scikit-learn
官网下载教程:Installing scikit-learn — scikit-learn 1.1.1 documentationpip install matplotlib
官网入门教程:Getting started — Matplotlib 3.5.3 documentationpip install wordcloud
pypi网站:wordcloud · PyPI(虽然网页上只说测试到了Python3.7,其实Python3.8也能用),文档:WordCloud for Python documentation — wordcloud 1.8.1 documentation,官方博文:A Wordcloud in Python,GitHub项目:amueller/word_cloud: A little word cloud generator in Pythonpip install gensim
官网:Gensim: Topic modelling for humanspip install pyldavis
官方文档:pyLDAvis — pyLDAvis 2.1.2 documentationpip install tqdm
官方GitHub项目:tqdm/tqdm: A Fast, Extensible Progress Bar for Python and CLIpip install seaborn
官网下载教程:Installing and getting started — seaborn 0.11.2 documentationpip install sentence_transformers
官网:sentence-transformers (Sentence Transformers)pip install pybind11
官网下载教程:Installing the library — pybind11 documentationpip install numpy==1.14
git clone https://github.com/shibing624/textgen.git
cd textgen
python setup.py install
通过源码安装包,在源码更新时同时更新包的方法:
(待补)
pip install torch_scatter-2.0.9-cp39-cp39-linux_x86_64.whl
--upgrade
或 -U
更新包到最新版本,示例代码:pip install --upgrade numpy
(文档地址:https://pip.pypa.io/en/stable/cli/pip_install/#cmdoption-U)--pre
下载pre-release或development版本。(默认情况下pip会搜索stable版本的包) 示例代码:pip install --pre dgl-cu102 -f https://data.dgl.ai/wheels-test/repo.html
-i
指定源,示例代码:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple cogdl
https://pypi.tuna.tsinghua.edu.cn/simple
pypi | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror-e, --editable <path/url>
以editable mode,从本地项目路径或一个VCS URL安装包。示例代码:pip install -e .
--user
安装到Python用户的install directory里,一般来说是~/.local/
,Windows平台一般是%APPDATA%Python
,可以查看Python文档里的site.USER_BASE(对应网址:site — Site-specific configuration hook — Python 3.10.4 documentation)来了解详情。(文档地址:https://pip.pypa.io/en/stable/cli/pip_install/#install-user)-i, --index-url <url>
Python包搜索位置。默认值:https://pypi.org/simple--extra-index-url <url>
--index-url
的补充超链接-f-
可以指定在某网页中搜索下载指定版本的包(一般都是包官方给出的安装方式),示例代码:pip install torch-scatter -f https://data.pyg.org/whl/torch-1.10.0+cu102.html
pip show
展示包的信息,示例代码:pip show numpy
打印信息:
Name: numpy
Version: 1.21.2
Summary: NumPy is the fundamental package for array computing with Python.
Home-page: https://www.numpy.org
Author: Travis E. Oliphant et al.
Author-email:
License: BSD
Location: /home/myusername/anaconda3/envs/envname/lib/python3.8/site-packages
Requires:
Required-by: transformers, torchvision, torch, scipy, pandas, mkl-random, mkl-fft, matplotlib
pip list
打印已安装的包的简略信息Package Version
----------------------------- ----------
anyio 3.4.0
argon2-cffi 20.1.0
async-generator 1.10
attrs 21.2.0
Babel 2.9.1
backcall 0.2.0
backports.functools-lru-cache 1.6.4
pip cache dir
打印pip的cache文件夹pip cache purge
手动清除缓存2which pip
打印pip的路径.pip/pip.conf
(Linux/Unix)或%HOME%\pip\pip.ini
(Windows)文件中添加以下内容:[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
.condarc
中增加如下内容3:show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
deepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。