简体   繁体   English

如何从docker-compose安装requirements.txt?

[英]How can I install requirements.txt from docker-compose?

I have created a dockerized django app using docker-compose(following this tutorial). 我使用docker-compose创建了一个dockerized django应用程序(遵循教程)。 Now I want to add some packages to requirements.txt and install them. 现在我想将一些包添加到requirements.txt并安装它们。 What is the right way to do that? 这样做的正确方法是什么?

From the tutorial you point to - the statement 从您指向的教程 - 声明

ADD requirements.txt /code/ copies requirements.txt file from your current directory on the host into /code/ directory inside the container. ADD requirements.txt /code/ copies requirements.txt文件从主机上的当前目录到容器内的/code/目录。 When docker-compose run command is executed, it first builds the container at which point it loads the 'requirements.txt' file into it. 当执行docker-compose run命令时,它首先构建容器,此时它将'requirements.txt'文件加载到其中。

So if you want to make changes to it, do it locally before you run compose. 因此,如果您想对其进行更改,请在运行撰写之前在本地执行此操作。 This will build and run your dockerized app with the new packages in your modified requirements.txt file. 这将使用修改后的requirements.txt文件中的新包构建并运行您的dockerized应用程序。

Go into your virtual environment. 进入你的虚拟环境。 Your file name is requirements.txt 您的文件名是requirements.txt

You need to type in the terminal 您需要输入终端

pip install -r requirements.txt

This should install all the packages listed in your requirements.txt 这应该安装您的requirements.txt中列出的所有包

In case when some of your modules failed to install you have to manually install them. 如果某些模块安装失败,您必须手动安装它们。

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

相关问题 防止 docker-compose 在使用构建的镜像时重新安装 requirements.txt - Prevent docker-compose from reinstalling requirements.txt while using a built image 如何从 requirements.txt 在 Windows 10 上安装 Auto-PyTorch? - How can I install Auto-PyTorch on Windows 10 from requirements.txt? 如何根据本地目录中的 requirements.txt 文件使用 pip 安装软件包? - How can I install packages using pip according to the requirements.txt file from a local directory? 无法安装requirements.txt - Can not install requirements.txt 我可以通过 Docker 组合将两个 requirements.txt 文件合并为一个吗? - Can I merge two requirements.txt files to one via Docker compose? 如何安装 github zip 文件与 pip 和 setup.py 来自 requirements.txt? - How can I install a github zip file with pip and setup.py from requirements.txt? Docker撰写安装需求.txt - Docker compose installing requirements.txt 如何使用 `pip install -r requirements.txt` 通过 `requirements.txt` 下载 NLTK 语料库? - How can I download NLTK corpora via `requirements.txt` using `pip install -r requirements.txt`? 如何将依赖项与requirements.txt分开? - How can I separate out dependencies from requirements.txt? 我如何下载requirements.txt? - How can i download requirements.txt?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM