Python,使用`pip`安装第三方软件包

Python标准库包含大量可简化我们的Python开发需求的实用程序,但没有什么可以满足一切

这就是个人和公司创建软件包并将其作为整个社区的开源软件提供的原因。

这些模块全部收集在一个地方,Python包索引可在https://pypi.org,并且可以使用来将它们安装在您的系统上pip

在撰写本文时,有超过270.000个软件包免费提供。

你应该有pip如果您已按照Python安装说明进行了安装,则说明已安装。

使用以下命令安装任何软件包pip install

pip install <package>

or, if you do have troubles, you can also run it through python -m:

python -m pip install <package>

For example you can install the requests package, a popular HTTP library:

pip install requests

and once you do, it will be available for all your Python scripts, because packages are installed globally.

The exact location depends on your operating system.

On macOS, running Python 3.9, the location is /Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages.

Upgrade a package to its latest version using:

pip install –U <package>

Install a specific version of a package using:

pip install <package>==<version>

Uninstall a package using:

pip uninstall <package>

Show an installed package details, including version, documentation website and author information using:

pip show <package>  

More python tutorials: