Requirement.txt 文件用于在使用 conda 环境时进行 Render。

huangapple go评论48阅读模式
英文:

Requirement.txt file for Render while using conda environment

问题

我是新手,但我正在尝试使用Render的Web服务设置Flask应用程序,我在requirements.txt文件上遇到问题,部署一直失败。

我已经使用conda创建了虚拟环境,并使用"conda list -e > requirements.txt"命令创建了要求文件,但似乎无法使其工作。在服务器端的构建命令中,我尝试了默认选项:$ pip install -r requirements.txt,但没有起作用,以及$ conda install --file requirements.txt,但它没有识别conda命令。我应该怎么做?

英文:

I am new with this stuff but I am trying to set up flask app using Render's web service and I have problem with requirements.txt file and deploying keeps failing.

I have created virtual environment with conda and made requirement file using "conda list -e > requirements.txt" command but can't seem to make it work. As build command in server side I tried default option: $ pip install -r requirements.txt which didnt work and $ conda install --file requirements.txt but it didn't recognize conda command. What should I do?

答案1

得分: 1

conda export 和 pip export 的格式不同。如果你想要以 pip 格式导出依赖项,请使用:

pip freeze > requirements.txt

然后只需使用 pip install -r requirements.txt

如果你想要创建一个新的环境,并使用由 conda 导出的 requirements.txt 文件,请使用:

conda list -e > requirements.txt

然后:

conda create --name <your-new-env> --file <requirements file>

但如果你需要在现有环境中安装依赖项,请使用:

conda install --file <requirements file>

关于为什么无法识别 conda 命令,请提供更多信息更新你的问题,我会相应编辑我的回答。

英文:

conda export and pip export don't have the same format. If you want to export dependencies in pip format use:

pip freeze &gt; requirements.txt

And then just use pip install -r requirements.txt

If you want to make a new env that will use requirements.txt file exported by conda, use:

conda list -e &gt; requirements.txt

and then:

conda create --name &lt;your-new-env&gt; --file &lt;requirements file&gt;

But if you need to install dependencies in an existing env, use the:

conda install --file &lt;requirements file&gt;

As to why it didn't recognize conda command, please update your question with more info, and I will edit my answer accordingly.

huangapple
  • 本文由 发表于 2023年4月17日 04:56:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76030306.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定