[英]Python - Running an pip installed package from cli
I just came across a pip package I want to use however I'm new to python and PIP and not sure - is it possible to run that directly from terminal/the command line. I just came across a pip package I want to use however I'm new to python and PIP and not sure - is it possible to run that directly from terminal/the command line. If so, I can't seem to find the syntac to run a pip package.如果是这样,我似乎找不到运行 pip package 的语法。
So I installed pip using:所以我安装了 pip 使用:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
then然后
python get-pip.py
I then checked installation, by the command python -m pip
然后我通过命令python -m pip
检查安装
I then installed the package like:然后我安装了 package,如:
python -m pip install openapi-cli-tool
Anyhow, as per the docs of that package I though I could just do:无论如何,根据 package 的文档,我虽然可以这样做:
openapi-cli-tool bundle -t html file1.json file2.yaml` > ./specification.html
Which didn't work, neither did this:哪个没有用,这个也没有:
python -p pip openapi-cli-tool bundle -t html file1.json file2.yaml` > ./specification.html
Any help in explaining how this works would be appreciated.任何帮助解释这是如何工作的都将不胜感激。
You have to install it with pip, run command below:您必须使用 pip 安装它,运行以下命令:
pip install openapi-cli-tool
Then openapi-cli-tool
will be available in your terminal, so you shall be able to run command, the command below is with correction of parameters passing:然后openapi-cli-tool
将在您的终端中可用,因此您应该能够运行命令,以下命令用于更正参数传递:
Make sure you have file1.json and file2.yaml in file system.确保文件系统中有 file1.json 和 file2.yaml。
openapi-cli-tool bundle -t html file1.json file2.yaml` > ./specification.html
python -m pip install
Installs the package to the user's local directory (iirc)将 package 安装到用户的本地目录 (iirc)
So, you can access it from ~/.local/bin/
, like this:因此,您可以从~/.local/bin/
访问它,如下所示:
~/.local/bin/openapi-cli-tool bundle -t html file1.json file2.yaml` > ./specification.html
You can add ~/.local/bin
to your path by您可以将~/.local/bin
添加到您的路径中
export PATH=$PATH:$HOME/.local/bin
and probably add that line to your .bashrc
or it's equivalent.并且可能将该行添加到您的.bashrc
或它的等价物。
Then, you can access it by just openapi-cli-tool bundle
然后,您可以通过openapi-cli-tool bundle
访问它
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.