在conda中创建requirements.txt文件时不显示版本信息。

14 浏览
0 Comments

在conda中创建requirements.txt文件时不显示版本信息。

我一直在conda环境(python==3.6)中工作。我尝试使用以下命令创建requirements.txt文件:pip freeze > requirements.txt。文件显示如下:pandas @ file:///C:/ci/pandas_1602088210462/workPillow @ file:///C:/ci/pillow_1609842634117/work。我原本期望看到:pandas==1.1.3。有人有解决方法吗?

0
0 Comments

在使用conda创建requirements.txt文件时,不会显示版本号的原因是因为conda不会导出符合PyPI包规范的版本信息。解决方法是可以使用以下命令导出符合conda规范的包列表,并通过conda进行安装:

conda list --export > requirements.txt
conda install --file requirements.txt

另外,也可以使用以下命令将包列表导出为符合pip规范的版本信息:

pip list --format=freeze > requirements.txt

然而,需要注意的是,使用conda导出的包列表将包含conda自身的包,而不是PyPI的包,因此可能不兼容使用pip进行安装:

pip install -r requirements.txt

因此,如果需要导出符合PyPI规范的包列表,建议使用pip命令导出requirements.txt文件。

0