为什么 python 依赖项没有安装?

发布于 2025-01-16 10:13:59 字数 445 浏览 3 评论 0原文

我试图创建一个从 github-actions 到 ec2 的 ci-cd 工作流程。但工作流程的一部分不起作用。有一部分我们可以使用 shell 文件安装 python 依赖项。但访问requirements.txt时出现问题。请帮帮我。

这是我的 shell 脚本:

sudo pip3 install virtualenv
cd /home/ec2-user/app/Phalguna
virtualenv environment
source environment/bin/activate
sudo pip3 freeze > requirements.txt
sudo pip3 install -r requirements.txt

这是我的错误:错误:无法打开需求文件:[Errno 2] 没有这样的文件或目录:'requirements.txt'

i was trying to create a ci-cd workflow from github-actions to ec2. but a part of the workflow is not working. there is a part where we can install the python dependencies using a shell file. but there is a problem while accessing requirements.txt . please help me out.

this is my shell script:

sudo pip3 install virtualenv
cd /home/ec2-user/app/Phalguna
virtualenv environment
source environment/bin/activate
sudo pip3 freeze > requirements.txt
sudo pip3 install -r requirements.txt

and this is my error: ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不爱素颜 2025-01-23 10:13:59

正如您可以在此处阅读的第一句话:
https://pip.pypa.io/en/stable/cli/pip_freeze/< /a>

“以需求格式输出已安装的软件包。”

您刚刚创建了一个新的虚拟环境,没有安装任何软件包。因此,pip freeze 当然不可能输出应用程序的任何依赖项。您必须在已安装所有软件包的测试环境中执行此操作,并将其与应用程序的其余部分一起发布。

As you can read in the first sentence here:
https://pip.pypa.io/en/stable/cli/pip_freeze/

"Output installed packages in requirements format."

You have just created a new virtual environment with no installed packages. So pip freeze, of course, cannot possibly output any dependency of your application. You have to do it from your testing environment with all the packages already installed and ship it with the rest of your application.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文