【问题标题】:Pip freeze > requirements doesn't work well with anacondaPip freeze > requirements 不适用于 anaconda
【发布时间】:2021-04-04 12:25:13
【问题描述】:

我正在尝试基于另一个虚拟环境创建一个虚拟环境,为此,我想使用 pip freeze> requirements.txt 从库中提取信息以用于 Django 环境

但是输出是

asgiref @ file:///tmp/build/80754af9/asgiref_1605055780383/work
certifi==2020.12.5
cffi==1.14.5
chardet==4.0.0
cryptography==3.4.7
cycler==0.10.0
Django @ file:///tmp/build/80754af9/django_1613762073373/work
django-clear-cache==0.3
djangorestframework==3.12.4
idna==2.10
kiwisolver==1.3.1
matplotlib==3.4.1
numpy==1.20.2
Pillow==8.2.0
psycopg2 @ file:///C:/ci/psycopg2_1612298766762/work
pycparser==2.20
PyMySQL==1.0.2
pyparsing==2.4.7
PyQt5==5.15.4
PyQt5-Qt5==5.15.2
PyQt5-sip==12.8.1
python-dateutil==2.8.1
pytz @ file:///tmp/build/80754af9/pytz_1612215392582/work
requests==2.25.1
six==1.15.0
sqlparse @ file:///tmp/build/80754af9/sqlparse_1602184451250/work
urllib3==1.26.4
wincertstore==0.2

当我尝试 pip install -r requirements.txt 时不起作用。

输出

Processing c:\tmp\build\80754af9\asgiref_1605055780383\work
ERROR: Could not install packages due to an OSError: [Errno 2] No such file or directory: 'C:\\tmp\\build\\80754af9\\asgiref_1605055780383\\work'

所以我需要一种方法来使用 pip 提取信息并在另一个环境中使用 pip 安装它。

【问题讨论】:

    标签: python django pip


    【解决方案1】:

    如果您想使用 pip 提取您的需求,而不需要任何其他信息(如您发布的信息),请使用:

    pip list --format=freeze > requirements.txt
    

    【讨论】:

      【解决方案2】:

      你可以的

      conda list --export > requirements.txt
      

      获取所有依赖项。

      在创建具有需求依赖项的新 conda 环境时,请使用

      conda create --name <envname> --file requirements.txt
      

      要了解更多关于 condapip 的区别,请参阅 here

      您可能还会发现this 表很有帮助,它比较了pipconda 的不同命令

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2019-06-04
        • 2019-12-24
        • 1970-01-01
        • 1970-01-01
        • 2016-09-19
        • 2019-12-17
        • 1970-01-01
        相关资源
        最近更新 更多