Python-从cli运行pip安装的软件包

时间:2020-05-26 08:41:56

标签: python bash pip

我刚遇到pip package I want to use,但是我是python和PIP的新手,不确定-是否可以直接从终端/命令行运行它。如果是这样,我似乎找不到运行pip包的语法。

所以我使用以下方法安装了pip:

curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py

然后

python get-pip.py

然后我通过命令python -m pip

检查安装

然后,我像这样安装软件包:

python -m pip install openapi-cli-tool

无论如何,根据该软件包的文档,尽管我可以这样做:

openapi-cli-tool bundle -t html file1.json file2.yaml` > ./specification.html

什么都不起作用,这也不起作用:

python -p pip openapi-cli-tool bundle -t html file1.json file2.yaml` > ./specification.html

任何帮助您解释其工作原理的帮助。

2 个答案:

答案 0 :(得分:0)

您必须使用pip进行安装,请运行以下命令:

pip install openapi-cli-tool

然后openapi-cli-tool将在您的终端中可用,因此您将能够运行命令,下面的命令带有对传递的参数的校正:

确保文件系统中有file1.json和file2.yaml。

openapi-cli-tool bundle -t html file1.json file2.yaml` > ./specification.html

答案 1 :(得分:0)

git worktree add

将软件包安装到用户的本地目录(iirc)

因此,您可以从python -m pip install 访问它,如下所示:

~/.local/bin/

您可以通过以下方式将~/.local/bin/openapi-cli-tool bundle -t html file1.json file2.yaml` > ./specification.html 添加到路径中

~/.local/bin

,可能将该行添加到您的export PATH=$PATH:$HOME/.local/bin 或等效行中。

然后,您只需.bashrc

即可访问它