热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

linux中安装pip_如何在Linux中安装PIP

linux中安装pipInthistutorial,we’llgooverthestepstoinstallpipinLinux.Thepipcommandallowsustoi

linux中安装pip

In this tutorial, we’ll go over the steps to install pip in Linux. The pip command allows us to install Python packages from the Python Package Index or PyPI.

在本教程中,我们将介绍在Linux中安装pip的步骤。 pip命令允许我们从Python Package Index或PyPI安装Python软件包。

The pip command can be installed with the package manager for your Linux distribution. In this tutorial, we’ll work with Ubuntu’s apt package manager to install pip.

pip命令可以与Linux发行版的软件包管理器一起安装。 在本教程中,我们将与Ubuntu的apt软件包管理器一起安装pip。


什么是Python PIP? (What is Python PIP)

The pip command stands for Package Installer for Python. Similar to the apt command for Debian-based distributions, yum and rpm commands for Red Hat-based distributions, and pacman for Arch-based distributions, pip command helps install packages for Python.

pip命令代表Python的软件包安装程序。 与基于Debian的发行版的apt命令,基于Red Hat的发行版的yum和rpm命令以及基于Arch的发行版的pacman相似,pip命令有助于安装Python软件包。

When you’re working with Python, you can install the available packages using the system’s default package manager or work with pip to install Python-specific packages directly from their official index.

使用Python时,您可以使用系统的默认软件包管理器来安装可用的软件包,或者与pip一起直接从其官方索引中安装特定于Python的软件包。

With the default package manager, there will always be packages that just aren’t available. But with pip, you can rest assured that most of the packages that you’ll require (and many more) will be available right there.

使用默认的程序包管理器,总是会有一些不可用的程序包。 但是,有了pip,您可以放心,所需的大多数软件包(以及更多软件包)都将在那里提供。


如何在Linux中安装Pip? (How To Install Pip In Linux)

So how do we go about installing pip in Linux It’s really simple. Let’s walk through the simple steps to get pip up and running on our Ubuntu server here.

那么,如何在Linux中安装pip? 真的很简单。 让我们通过简单的步骤在此处的Ubuntu服务器上启动并运行。

root@ubuntu:~# apt -y install python-pip
OR
root@ubuntu:~# apt -y install python3-pip

Install Pip in Linux

Python3 Pip Installation

Python3 Pip安装

If you’re using a different distribution of Linux, there’s nothing to worry about. Simply change the apt install part with your package manager.

如果您使用的是其他发行版的Linux,则无需担心。 只需使用包管理器更改apt安装部分。

For example, on an Arch-based system, you’d type

例如,在基于Arch的系统上,您可以输入

root@arch:~# pacman -S python2-pip
root@arch:~# pacman -S python-pip #This installs python3 pip

You can use python-pip (for python version 2) and python3-pip (for python version 3).

您可以使用python-pip(适用于python版本2)和python3-pip(适用于python版本3)。

Depending on which version of Python you’re working with, you can install pip or pip3 and make sure that you have the right packages being installed.

根据您使用的Python版本,可以安装pip或pip3并确保已安装正确的软件包。


如何在Linux中使用PIP命令? (How to Use PIP Command in Linux)

Now coming to the usage of PIP, we’ll learn how to

现在开始使用PIP,我们将学习如何


  • install

    安装

  • uninstall

    卸载

  • search

    搜索

  • list existing packages

    列出现有软件包

  • show details of a package

    显示包裹的细节

I’ve installed python3-pip on Ubuntu since I mostly work with Python 3.x. You can replace the pip3 part in the below examples with pip if you’re working with pip for Python 2.x.

因为我主要使用Python 3.x,所以我已经在Ubuntu上安装了python3-pip。 如果您正在使用适用于Python 2.x的pip,则可以将以下示例中的pip3部分替换为pip。

We’ll install the numpy library as an example here.

我们将在此处安装numpy库作为示例。

root@ubuntu:~# pip3 install
For Example --
root@ubuntu:~# pip3 install numpy

Pip Install Example

Pip Install Example

点安装示例

If you would like to know what packages are available, you can use the search functionality of the pip command.

如果您想知道可用的软件包,可以使用pip命令搜索功能。

root@ubuntu:~# pip3 search numpy

Pip Search Example

Pip Search Example

点搜索示例

How to find the list of installed Python packages We’ll use the list option for the pip command.

如何找到已安装的Python软件包列表? 我们将对pip命令使用list选项。

root@ubuntu:~# pip3 list

Pip List Example

Pip List Example

点列表示例

You can safely ignore the warning in the output because it’s just to let us know that the default output format will change in the future.

您可以放心地忽略输出中的警告,因为这只是为了告诉我们默认输出格式将来会更改。

If you’d like to know more about a package that you’ve installed, just use the show command.

如果您想了解有关已安装软件包的更多信息,请使用show命令。

root@ubuntu:~# pip3 uninstall numpy

Pip Show Example

Pip Show Example

点显示示例

And to uninstall a package, we simply use pip3 uninstall as below.

要卸载软件包,我们只需使用pip3卸载 ,如下所示。

root@ubuntu:~# pip3 uninstall numpy

Pip Uninstall Example

Pip Uninstall Example

点卸载示例


结论 (Conclusion)

I know, it was really easy to install pip in Linux so I took the liberty to explain how you can start with using the command right away. As you work with Python, you’ll find yourself working with the pip command very often for installing and uninstalling packages.

我知道,在Linux中安装pip真的很容易,所以我自由地解释了如何立即使用该命令。 使用Python时,您会发现自己经常使用pip命令来安装和卸载软件包。

We hope you enjoyed this tutorial!

希望您喜欢本教程!


翻译自: https://www.journaldev.com/33905/install-pip-linux


linux中安装pip


推荐阅读
  • 在Docker中,将主机目录挂载到容器中作为volume使用时,常常会遇到文件权限问题。这是因为容器内外的UID不同所导致的。本文介绍了解决这个问题的方法,包括使用gosu和suexec工具以及在Dockerfile中配置volume的权限。通过这些方法,可以避免在使用Docker时出现无写权限的情况。 ... [详细]
  • Linux服务器密码过期策略、登录次数限制、私钥登录等配置方法
    本文介绍了在Linux服务器上进行密码过期策略、登录次数限制、私钥登录等配置的方法。通过修改配置文件中的参数,可以设置密码的有效期、最小间隔时间、最小长度,并在密码过期前进行提示。同时还介绍了如何进行公钥登录和修改默认账户用户名的操作。详细步骤和注意事项可参考本文内容。 ... [详细]
  • Centos7.6安装Gitlab教程及注意事项
    本文介绍了在Centos7.6系统下安装Gitlab的详细教程,并提供了一些注意事项。教程包括查看系统版本、安装必要的软件包、配置防火墙等步骤。同时,还强调了使用阿里云服务器时的特殊配置需求,以及建议至少4GB的可用RAM来运行GitLab。 ... [详细]
  • 本文介绍了Linux系统中正则表达式的基础知识,包括正则表达式的简介、字符分类、普通字符和元字符的区别,以及在学习过程中需要注意的事项。同时提醒读者要注意正则表达式与通配符的区别,并给出了使用正则表达式时的一些建议。本文适合初学者了解Linux系统中的正则表达式,并提供了学习的参考资料。 ... [详细]
  • 成功安装Sabayon Linux在thinkpad X60上的经验分享
    本文分享了作者在国庆期间在thinkpad X60上成功安装Sabayon Linux的经验。通过修改CHOST和执行emerge命令,作者顺利完成了安装过程。Sabayon Linux是一个基于Gentoo Linux的发行版,可以将电脑快速转变为一个功能强大的系统。除了作为一个live DVD使用外,Sabayon Linux还可以被安装在硬盘上,方便用户使用。 ... [详细]
  • 学习SLAM的女生,很酷
    本文介绍了学习SLAM的女生的故事,她们选择SLAM作为研究方向,面临各种学习挑战,但坚持不懈,最终获得成功。文章鼓励未来想走科研道路的女生勇敢追求自己的梦想,同时提到了一位正在英国攻读硕士学位的女生与SLAM结缘的经历。 ... [详细]
  • 本文介绍了设计师伊振华受邀参与沈阳市智慧城市运行管理中心项目的整体设计,并以数字赋能和创新驱动高质量发展的理念,建设了集成、智慧、高效的一体化城市综合管理平台,促进了城市的数字化转型。该中心被称为当代城市的智能心脏,为沈阳市的智慧城市建设做出了重要贡献。 ... [详细]
  • 本文讨论了在Windows 8上安装gvim中插件时出现的错误加载问题。作者将EasyMotion插件放在了正确的位置,但加载时却出现了错误。作者提供了下载链接和之前放置插件的位置,并列出了出现的错误信息。 ... [详细]
  • [译]技术公司十年经验的职场生涯回顾
    本文是一位在技术公司工作十年的职场人士对自己职业生涯的总结回顾。她的职业规划与众不同,令人深思又有趣。其中涉及到的内容有机器学习、创新创业以及引用了女性主义者在TED演讲中的部分讲义。文章表达了对职业生涯的愿望和希望,认为人类有能力不断改善自己。 ... [详细]
  • 本文介绍了Hyperledger Fabric外部链码构建与运行的相关知识,包括在Hyperledger Fabric 2.0版本之前链码构建和运行的困难性,外部构建模式的实现原理以及外部构建和运行API的使用方法。通过本文的介绍,读者可以了解到如何利用外部构建和运行的方式来实现链码的构建和运行,并且不再受限于特定的语言和部署环境。 ... [详细]
  • 关键词:Golang, Cookie, 跟踪位置, net/http/cookiejar, package main, golang.org/x/net/publicsuffix, io/ioutil, log, net/http, net/http/cookiejar ... [详细]
  • 本文介绍了在多平台下进行条件编译的必要性,以及具体的实现方法。通过示例代码展示了如何使用条件编译来实现不同平台的功能。最后总结了只要接口相同,不同平台下的编译运行结果也会相同。 ... [详细]
  • Go Cobra命令行工具入门教程
    本文介绍了Go语言实现的命令行工具Cobra的基本概念、安装方法和入门实践。Cobra被广泛应用于各种项目中,如Kubernetes、Hugo和Github CLI等。通过使用Cobra,我们可以快速创建命令行工具,适用于写测试脚本和各种服务的Admin CLI。文章还通过一个简单的demo演示了Cobra的使用方法。 ... [详细]
  • CEPH LIO iSCSI Gateway及其使用参考文档
    本文介绍了CEPH LIO iSCSI Gateway以及使用该网关的参考文档,包括Ceph Block Device、CEPH ISCSI GATEWAY、USING AN ISCSI GATEWAY等。同时提供了多个参考链接,详细介绍了CEPH LIO iSCSI Gateway的配置和使用方法。 ... [详细]
  • (三)多表代码生成的实现方法
    本文介绍了一种实现多表代码生成的方法,使用了java代码和org.jeecg框架中的相关类和接口。通过设置主表配置,可以生成父子表的数据模型。 ... [详细]
author-avatar
body胤ly_680
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有