简体   繁体   English

从requirements.txt安装选定的软件包

[英]Installing selected packages from requirements.txt

I have a requirements.txt file on my development machine. 我的开发机器上有一个requirements.txt文件。 I have pushed it into a git repo and cloned it on a server. 我已经将其推入git repo并将其克隆到服务器上。

The way I push changes to the server is as follows: 我将更改推送到服务器的方式如下:

I freeze the file on my development machine, then I add the file to git and pull it on the server and do pip install -r requirements.txt. 我将文件冻结在开发机器上,然后将文件添加到git并将其拉到服务器上,然后执行pip install -r requirements.txt。

But doing this is installing all the packages again and again and I dont want that. 但是这样做是一次又一次地安装所有软件包,我不希望那样。 I only want those packages to be installed which are not installed on the server. 我只希望安装那些未安装在服务器上的软件包。

Whats the best way of doing this? 最好的方法是什么? I would also like to know other efficient methods of pushing development code to server. 我还想知道将开发代码推送到服务器的其他有效方法。

Use buildout , this is other method. 使用buildout ,这是另一种方法。 Buildout checks for packages before installing, so it will not reinstall unneeded packages. Buildout在安装之前会检查软件包,因此不会重新安装不需要的软件包。

It is very powerfull tool. 这是非常强大的工具。 When you deploy, you just need to make git push , then on the production server you do: 部署时,只需执行git push ,然后在生产服务器上执行以下操作:

git pull
bin/buildout

That's it. 而已。 You can read an article about Buildout and pip+virtualenv differences 您可以阅读有关Buildout和pip + virtualenv差异的文章

EDIT: 编辑:


You can set PIP_DOWNLOAD_CACHE path in settings.py to tell pip store all downloaded packages in some directory(' packages ' for example), so it won't download them again: 您可以在settings.py设置PIP_DOWNLOAD_CACHE路径,以告诉pip将所有下载的软件包存储在某个目录中(例如“ packages ”),这样就不会再次下载它们:

import os.path

PROJECT_ROOT = os.path.normpath(os.path.dirname(__file__))
PIP_DOWNLOAD_CACHE = os.path.abspath(PROJECT_ROOT+'/packages/'),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Jedi python 在从 requirements.txt 安装软件包时未安装 - Jedi python is not installing while installing packages from requirements.txt 通过从 python 文件中引用来安装 requirements.txt 中的软件包 - Installing packages present in requirements.txt by referencing it from a python file 从 github repo 中的 requirements.txt 安装包 - Installing packages from requirements.txt in github repo 从 python 项目的 requirements.txt 安装 R 包 - Installing R packages from python project's requirements.txt 从 python 3.9 中的 requirements.txt 安装软件包时出错 - Error while Installing Packages from requirements.txt in python 3.9 Azure 部署未安装 requirements.txt 中列出的 Python 包 - Azure deployment not installing Python packages listed in requirements.txt 使用 requirements.txt 文件安装 python 包 - Installing python packages using requirements.txt file cffi (setup.py) 的构建轮...在 django 中从 requirements.txt 安装软件包时出错 - Building wheel for cffi (setup.py) ... error while installing the packages from requirements.txt in django 当我使用requirements.txt时,pip无法从virtualenv内安装到site-packages目录 - pip not installing to site-packages directory from within virtualenv when I use a requirements.txt 使用 pip 命令从 requirements.txt 升级 python 包 - Upgrade python packages from requirements.txt using pip command
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM