[root@localhost ~]# pip3 --help
Usage:
pip3 <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: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
安装指定包的最新版
pip3 install pkg_name
安装制定包的指定版本
pip3 install pkg_name==version
移除指定包
pip3 uninstall pkg_name
在 PyPI 上模糊查找相关包
pip3 search pkg_name
pip install/download
install是联网安装,而download是本地离线下载
pip download pkg_name -d download_path
查看已经安装的包
pip3 list
[root@localhost ~] pip3 list
Package Version
------------------ ---------
aiohttp 3.7.4
amqp 5.0.5
async-timeout 3.0.1
attrs 20.3.0
pip3 show pkg_name
[root@localhost ~] pip3 show zipp
Name: zipp
Version: 3.4.0
Summary: Backport of pathlib-compatible object wrapper for zip files
Home-page: https://github.com/jaraco/zipp
Author: Jason R. Coombs
Author-email: jaraco@jaraco.com
License: UNKNOWN
Location: /usr/local/python3/lib/python3.8/site-packages
Requires:
Required-by: importlib-metadata, ratel
Requires 和 Required-by 两个属性分别表示 zip 要依赖和被依赖的包情况;zipp 不需要任何依赖,而 zipp 被importlib-metadata和ratel依赖,所以删除之后会影响这两个的使用,最好对request 所有的依赖依次使用 pip show 运行一下查看具体依赖情况。
输出所有在本地已安装的包
pip3 freeze: 使用 pip freeze 会输出所有在本地已安装的包(但不包括 pip、wheel、setuptools 等自带包),若需要输出内容与 pip list 一致,需使用 pip freeze -all。
[root@localhost ~] pip3 freeze all
aiohttp==3.7.4
amqp==5.0.5
async-timeout==3.0.1
attrs==20.3.0
Automat==20.2.0
beautifulsoup4==4.9.3
pip3 freeze > requirements.txt: 当我们开发项目的时候会出现在不同环境下安装相同的模块的时为了避免我们通过联网下载所需模块,我们直接从之前python环境已经有的模块中直接拿来用。
所以一般这个命令需要虚拟环境来维护当前的包版本,防止不同项目的不同版本包放在一起会造成混乱

修改pip配置文件
pip3 config
国内源
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:http://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
山东理工大学:http://pypi.sdutlinux.org/
豆瓣:http://pypi.douban.com/simple/
pip config set
这个命令允许我们以name=value的形式配置某些项,比如设置镜像源:
pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple
pip config get
这个命令允许我们查看某个配置项的值,比如查看镜像源配置:
pip config get global.index-url
pip config edit
这个命令允许我们用一个编辑器打开配置文件进行编辑,如果我们没有指定--editor选项,就会用VISUAL或者EDITOR环境变量的值作为编辑器,如下命令:
pip config --editor=vi edit
pip config list
这个命令以name=value的形式输出当前配置,假如我们已经执行了上面的pip config set命令,这时再执行 pip config list就会输出如下:
global.index-url='https://mirrors.cloud.tencent.com/pypi/simple'
pip3 config debug
这个命令列出各个配置文件位置及其内容
pip3 config unset
检查需要的包的缺失匹配情况
pip3 check
[root@localhost ~]# pip3 check
paramiko 2.10.3 requires bcrypt, which is not installed.
paramiko 2.10.3 requires cryptography, which is not installed.
pynacl 1.5.0 requires cffi, which is not installed.
pip3 --disable-pip-version-check install --no-index --find-links=
第一个参数 --disable-pip-version-check 后面跟着的注释大意为:不要定期检查PyPI以确定是否有新版本的pip可供下载。暗示和--no-index联用
意思就是一般在断网情况下的离线安装,都是直接从其他主机安装资源包,所以要取消更新
其中 --no-index 代表忽视pip 忽视默认的依赖包索引。--find-links= 代表从你指定的目录寻下找离线包
pip download --platform anylinux_x86_64 --no-deps on -d pip_packages/ -r project/requirements.txt
其中:--platform 指定平台信息, --no-deps:on 代表不安装依赖项。-d 后面指定依赖包下载目录。最后跟上requirement.txt。
我想用ruby编写一个小的命令行实用程序并将其作为gem分发。我知道安装后,Guard、Sass和Thor等某些gem可以从命令行自行运行。为了让gem像二进制文件一样可用,我需要在我的gemspec中指定什么。 最佳答案 Gem::Specification.newdo|s|...s.executable='name_of_executable'...endhttp://docs.rubygems.org/read/chapter/20 关于ruby-在Ruby中编写命令行实用程序
我从Ubuntu服务器上的RVM转移到rbenv。当我使用RVM时,使用bundle没有问题。转移到rbenv后,我在Jenkins的执行shell中收到“找不到命令”错误。我内爆并删除了RVM,并从~/.bashrc'中删除了所有与RVM相关的行。使用后我仍然收到此错误:rvmimploderm~/.rvm-rfrm~/.rvmrcgeminstallbundlerecho'exportPATH="$HOME/.rbenv/bin:$PATH"'>>~/.bashrcecho'eval"$(rbenvinit-)"'>>~/.bashrc.~/.bashrcrbenvversions
文章目录git常用命令(简介,详细参数往下看)Git提交代码步骤gitpullgitstatusgitaddgitcommitgitpushgit代码冲突合并问题方法一:放弃本地代码方法二:合并代码常用命令以及详细参数gitadd将文件添加到仓库:gitdiff比较文件异同gitlog查看历史记录gitreset代码回滚版本库相关操作远程仓库相关操作分支相关操作创建分支查看分支:gitbranch合并分支:gitmerge删除分支:gitbranch-ddev查看分支合并图:gitlog–graph–pretty=oneline–abbrev-commit撤消某次提交git用户名密码相关配置g
我有一个问题。我想从另一个ruby脚本运行一个ruby脚本并捕获它的输出信息,同时让它也输出到屏幕。亚军#!/usr/bin/envrubyprint"Enteryourpassword:"password=gets.chompputs"Hereisyourpassword:#{password}"我运行的脚本文件:开始.rboutput=`runner`putsoutput.match(/Hereisyour(password:.*)/).captures[0].to_s正如您在此处看到的那样,存在问题。在start.rb的第一行,屏幕是空的。我在运行程序中看不到“输入您的密
有这样的事吗?我想在Ruby程序中使用它。 最佳答案 试试这个http://csl.sublevel3.org/jp2a/此外,Imagemagick可能还有一些东西 关于ruby-是否有将图像文件转换为ASCII艺术的命令行程序或库?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/6510445/
我正在构建一个应用程序,想知道是否将未使用的对象设置为nil是生产级编码中的常见做法。我知道这只是垃圾收集器的提示,并不总是处理对象。 最佳答案 根据这个thread如果您使用完一个成员对象,将其设置为nil将引发被引用对象被垃圾回收。如果它是局部变量,方法exit将做同样的事情。也就是说,如果您要求将成员显式设置为nil,我会质疑您的设计。 关于ruby-将对象设置为nil是否很常见?,我们在StackOverflow上找到一个类似的问题: https://
如何在Ruby的if语句中检查bash命令的返回值(true/false)。我想要这样的东西,if("/usr/bin/fswscell>/dev/null2>&1")has_afs="true"elsehas_afs="false"end它会提示以下错误含义,它总是返回true。(irb):5:warning:stringliteralincondition正确的语法是什么?更新:/usr/bin/fswscell寻找afs安装和运行状态。它会抛出这样的字符串,Thisworkstationbelongstocell如果afs没有运行,命令以状态1退出 最
在几个项目中,我希望有一个类似rakeserver的rake任务,它将通过任何需要的方式开始为该应用程序提供服务。这是一个示例:task:serverdo%x{bundleexecrackup-p1234}end这行得通,但是当我准备停止它时,按Ctrl+c并没有正常关闭;它中断了Rake任务本身,它说rakeaborted!并给出堆栈跟踪。在某些情况下,我必须执行Ctrl+c两次。我可能可以用Signal.trap写一些东西来更优雅地中断它。有没有更简单的方法? 最佳答案 trap('SIGINT'){puts"Yourmessa
关于SSHkit-Github它说:Allbackendssupporttheexecute(*args),test(*args)&capture(*args)来自SSHkit-Rubydoc,我明白execute实际上是test的别名?test之间有什么区别?,execute,capture在Capistrano/SSHKit中我应该什么时候使用? 最佳答案 执行只是执行命令。使用非0退出引发错误。测试方法的行为与execute完全相同,但是它返回bool值(true如果命令以0退出,而false否则)。它通常用于控制任务中的流程
我最近与一位同事讨论了以下Ruby语法:value=ifa==0"foo"elsifa>42"bar"else"fizz"end我个人并没有看到太多这种逻辑,但我的同事指出,这实际上是一种相当普遍的Rubyism。我试着用谷歌搜索这个主题,但没有找到任何文章、页面或SO问题来讨论它,这让我相信这可能是一种非常实际的技术。然而,另一位同事发现语法令人困惑,而是将上面的逻辑写成这样:ifa==0value="foo"elsifa>42value="bar"elsevalue="fizz"end缺点是value=的重复声明和隐式elsenil的丢失,如果我们想使用它的话。这也感觉它与Ruby