<分区>
我正在移植我的项目以支持 Python 3,它依赖于 SQLite,所以我的 requirements.txt 中有 pysqlite
但是 pysqlite 模块在 Python 3 中不存在(它是内置的),如何让我的 requirements.txt 在 Python 2 和 Python 3 中工作?
<分区>
我正在移植我的项目以支持 Python 3,它依赖于 SQLite,所以我的 requirements.txt 中有 pysqlite
但是 pysqlite 模块在 Python 3 中不存在(它是内置的),如何让我的 requirements.txt 在 Python 2 和 Python 3 中工作?
最佳答案
Pip(从 pip 6 开始)支持 environment markers .
要仅在 python < 3 上要求 pysqlite,请使用:
pysqlite ; python_version < '3'
https://pip.pypa.io/en/stable/reference/pip_install/#requirement-specifiers
关于python - 如何在 requirements.txt 中指定仅针对 Python 2(即不是 Python 3)的要求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34407802/
相关文章:
python - 如何导入使用 --user 选项安装的模块?
python-3.x - python 3.6.10 pip3 TLS/SSL 未配置
python - 无法使用 sasl python 模块构建 docker 镜像
python - 如何使用 pyspark SQL 获取基于时间的累计值?
python - 如何在本例中激活 ValidationError
Python 3.5 pip 9 属性错误 : 'NoneType' object has no attribute 'bytes'