如何在 Python 中为团队合作创建公共环境 [英] How to create a common environment for teamwork in Python

查看:67
本文介绍了如何在 Python 中为团队合作创建公共环境的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的团队创建一个虚拟环境.我的团队在不同的地方工作,每个人都有自己的环境,这会导致很多问题,每个人都有不同版本的库(Python、RobotFramework).

I would like to create a virtual environment for my team. My team, works in different places and everyone has their own environment, it causes a lot of problems, everyone has a different version of the libraries (Python, RobotFramework).

我想过:

  1. 创建一个通用环境,我使用了 virtualenv.
  2. 使用一个命令 pip install ... 安装准备好的库(python 和机器人框架),
  3. 准备好的库将在 git 存储库中,以便每个人都可以修改它们,更改库版本.

我已经完成了第一和第三部分,但第二部分有问题.如何创建这样一个库包,以便能够使用一个 pip install 命令安装它.

I have the first and third parts done, but I have a problem with the second. How to create such a package of libraries to be able to install it with one pip install command.

我是否应该在本地创建一个环境,在其中安装所有库,然后将它们发送到 git?或者我应该通过 setuptool 打包项目(到 tar.gz)?

Should I create an environment locally, install all the libraries in it, and send them to git? Or should I package the project via setuptool (to tar.gz)?

很遗憾,我找不到这个问题的答案,在我看来,以上解决方案都不是最佳的.

Unfortunately, I cannot find the answer to this question, it seems to me that none of the above solutions is optimal.

推荐答案

最简单的方法是使用命令创建您在 pip 中使用的所有库的文本文件.

The easiest way of doing it would be creating a text file of all the libraries you are using in pip with the command.

pip freeze > requirements.txt

这将创建一个文件,列出所有包及其正在使用的版本.要安装它,要求每个团队成员将该需求文件放在他们的项目中并使用

This will create a file listing all the packages with their versions that are being used. To install that ask every team member to place that requirement file in their projects and use

pip install -r requirements.txt

这篇关于如何在 Python 中为团队合作创建公共环境的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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