Skip to Content
Python实用技能学习指南
book

Python实用技能学习指南

by Posts & Telecom Press, Robert Smallshire, Austin Bingham
February 2024
Intermediate to advanced
316 pages
3h 47m
Chinese
Packt Publishing
Content preview from Python实用技能学习指南

附录C 安装第三方包

Python的打包有一个混乱并且令人困惑的历史。值得庆幸的是,现在情况已经稳定下来,一个名为pip的工具应运而生,该工具已经成为Python软件包安装工具中明显的领导者。对于依赖于NumpyScipy软件包的数字或科学计算等更多专业用途,你应该考虑使用Anaconda,这是一个强大的pip替代品。

在本附录中,我们将重点介绍pip,因为它是Python核心开发人员官方支持的,并且开箱即用。尽管pip不是用Python发布的,但是Python包含一个名为ensurepip的安装pip的工具。这样做是为了将pip安装到不同版本的Python语言和标准库中。

通常不需要在最近的Python版本中安装pip,因为在安装Python或创建新的虚拟环境时,系统会自动调用ensurepip。如果由于某种原因你需要手动安装pip,那么可以简单地调用以下命令:

$ python -m ensurepip

ensurepip模块会完成安装。请记住,该pip将被安装到你所调用的python解释器的相对应的环境中。

pip工具可用于搜索中央资源库(Python包索引,简称PyPI,昵称Cheeseshop)中的软件包,然后下载并安装它们以及它们所依赖的包。你可以通过Python官网进行下载。这种安装Python软件的方式非常方便,了解如何使用它很有用。

我们将通过安装nose测试工具来演示如何使用pipnose命令是一种强大的测试工具,它会运行基于单元测试的测试用例,例如我们在第10章中开发的那些测试用例。它真正有用的功能就是发现所有的测试并运行它们。这意味着你不需要在你的代码中添加unittest.main() ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

人工智能技术与大数据

人工智能技术与大数据

Posts & Telecom Press, Anand Deshpande, Manish Kumar
Kafka权威指南(第2版)

Kafka权威指南(第2版)

Gwen Shapira, Todd Palino, Rajini Sivaram, Krit Petty

Publisher Resources

ISBN: 9781835889626