相当于 npm 或 ruby​​gems 的 Python [英] Python equivalent of npm or rubygems

查看:30
本文介绍了相当于 npm 或 ruby​​gems 的 Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找可以与 python 一起使用的包管理器.我想在文件中列出项目依赖项.例如 ruby​​ 使用 Gemfile,您可以在其中使用 bundle install.我如何在 python 中实现这一点?

I've been looking around for a package manager that can be used with python. I want to list project dependencies in a file. For example ruby uses Gemfile where you can use bundle install. How can I achieve this in python?

推荐答案

pip 工具正在成为 Ruby gems 等价物的标准.与 distribute 一样,pip 使用 PyPI 包存储库(默认情况下)用于解析和下载依赖项.pip 可以从列出项目依赖项的文件(按照惯例称为 requirements.txt)安装依赖项:

The pip tool is becoming the standard in equivalent of Ruby's gems. Like distribute, pip uses the PyPI package repository (by default) for resolving and downloading dependencies. pip can install dependencies from a file listing project dependencies (called requirements.txt by convention):

pip install -r requirements.txt

您也可以使用 pip 冻结" Python 路径上的当前包:

You can "freeze" the current packages on the Python path using pip as well:

pip freeze > requirements.txt

virtualenv 包结合使用时,您可以使用项目所需的依赖项可靠地创建项目 Python 环境.

When used in combination with the virtualenv package, you can reliably create project Python environments with a project's required dependencies.

这篇关于相当于 npm 或 ruby​​gems 的 Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆