Python pip install -r requirements.txt [Errno 2] 没有这样的文件或目录:'requirements.txt'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/46854451/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
pip install -r requirements.txt [Errno 2] No such file or directory: 'requirements.txt'
提问by siama
I am setting up the base for a django project, I have cloned a repo and I have just created a virtual environment for the project in the same directory. But when I try to run the command 'pip install -r requirements.txt' in the project directory I get this error:
我正在为 django 项目设置基础,我已经克隆了一个 repo,我刚刚在同一目录中为该项目创建了一个虚拟环境。但是当我尝试在项目目录中运行命令“pip install -r requirements.txt”时,我收到此错误:
[Errno 2] No such file or directory: 'requirements.txt'
[Errno 2] 没有这样的文件或目录:'requirements.txt'
I believe I'm just running it in the wrong directory, but I don't really know where I should run it. Do you have any idea where the file could be located?
我相信我只是在错误的目录中运行它,但我真的不知道应该在哪里运行它。您知道该文件的位置吗?
回答by Abhi
I know it's kind of late, but if you are using virtual environment just use pip freeze > requirements.txt
command to create the requirements file first.
我知道这有点晚了,但是如果您使用的是虚拟环境,请先使用pip freeze > requirements.txt
命令创建需求文件。
回答by hermancaldara
A better way of doing this is write this on the root directory of your terminal:
更好的方法是在终端的根目录中写入:
find . -regex '.*requirements.txt$'
It will search in your root directory and all subfolders for a file called requirements.txt
. After the command response, you can get the directory and run the pip install -r requirements.txt
on it.
它将在您的根目录和所有子文件夹中搜索名为requirements.txt
. 命令响应后,您可以获取目录并在其pip install -r requirements.txt
上运行。
回答by Qasim Nadeem
If you are facing this issue while using a docker or flowing getting started guide from docker site then you need to update your Docker file.
如果您在使用 docker 或从 docker 站点获取入门指南时遇到此问题,那么您需要更新 Docker 文件。
just add following line to create the requirements.txt file before the line "RUN pip install --no-cache-dir -r requirements.txt" in your Dockerfile
只需添加以下行以在 Dockerfile 中的“RUN pip install --no-cache-dir -r requirements.txt”行之前创建 requirements.txt 文件
RUN pip freeze > requirements.txt
回答by pissall
Try using this in your terminal then go to the directory and use the pip install command.
尝试在终端中使用它,然后转到目录并使用 pip install 命令。
find -name "requirements.txt"
回答by vishwaraj
Check if you have requirements.txt
file in the directory.
and then run the following command.pip install -r requirements.txt
检查requirements.txt
目录中是否有文件。
然后运行以下命令。pip install -r requirements.txt
回答by Lutaaya Huzaifah Idris
Try to run this one in your terminal it will automatically list all the dependencies you have.
尝试在您的终端中运行这个,它会自动列出您拥有的所有依赖项。
NB:
注意:
it's recommended for flask development
推荐用于烧瓶开发
pip freeze > requirements.txt