pip freeze > requirements.txt 命令输出文件中出现文件路径而非版本号
pip freeze > requirements.txt
命令输出文件中出现文件路径而非版本号
问题现象
appdirs==1.4.4
black==21.6b0
certifi==2021.5.30
click @ file:///tmp/build/80754af9/click_1621604852318/work
colorama==0.4.4
dnspython==2.1.0
email-validator==1.1.3
Flask @ file:///home/ktietz/src/ci/flask_1611932660458/work
Flask-Login==0.5.0
flask-mongoengine==1.0.0
Flask-WTF==0.15.1
idna==3.2
importlib-metadata @ file:///C:/ci/importlib-metadata_1617877486026/work
itsdangerous @ file:///tmp/build/80754af9/itsdangerous_1621432558163/work
Jinja2 @ file:///tmp/build/80754af9/jinja2_1624781299557/work
MarkupSafe @ file:///C:/ci/markupsafe_1621528383308/work
mongoengine==0.23.1
mypy-extensions==0.4.3
pathspec==0.8.1
pymongo==3.12.0
regex==2021.7.6
toml==0.10.2
typed-ast==1.4.3
typing-extensions @ file:///tmp/build/80754af9/typing_extensions_1624965014186/work
Werkzeug @ file:///home/ktietz/src/ci/werkzeug_1611932622770/work
wincertstore==0.2
WTForms==2.3.3
zipp @ file:///tmp/build/80754af9/zipp_1625570634446/work
解决办法
pip list --format=freeze > requirements.txt
输出结果
appdirs==1.4.4
black==21.6b0
certifi==2021.5.30
click==8.0.1
colorama==0.4.4
dnspython==2.1.0
email-validator==1.1.3
Flask==1.1.2
Flask-Login==0.5.0
flask-mongoengine==1.0.0
Flask-WTF==0.15.1
idna==3.2
importlib-metadata==3.10.0
itsdangerous==2.0.1
Jinja2==3.0.1
MarkupSafe==2.0.1
mongoengine==0.23.1
mypy-extensions==0.4.3
pathspec==0.8.1
pip==21.1.3
pymongo==3.12.0
regex==2021.7.6
setuptools==52.0.0.post20210125
toml==0.10.2
typed-ast==1.4.3
typing-extensions==3.10.0.0
Werkzeug==1.0.1
wheel==0.36.2
wincertstore==0.2
WTForms==2.3.3
zipp==3.5.0
使用 Conda 管理环境依赖时
requirements.txt 与 environment.yml
# This file may be used to create an environment using:
# $ conda create --name <env> --file <this file>
# platform: linux-64
_libgcc_mutex=0.1=conda_forge
_openmp_mutex=4.5=2_gnu
name: base
channels:
- conda-forge
- defaults
dependencies:
- _libgcc_mutex=0.1
- _openmp_mutex=5.1
- pip:
- alembic==1.11.2
- amqp==5.1.1
requirements.txt
conda
批量导出包含环境中所有模块的requirements.txt
文件
conda list -e > requirements.txt
conda
批量安装requirements.txt
文件中包含的模块依赖
conda install --yes --file requirements.txt
environment.yml
conda
批量导出包含环境中所有模块的environment.yml
文件
conda env export --no-builds > environment.yml
conda
批量安装environment.yml
文件中包含的模块依赖
conda env create --file environment.yml
基于现有 Conda 环境进行克隆
conda create -n test --clone base
转载自:https://juejin.cn/post/7371662058645487643