安装Python、Flask与Google Cloud BigQuery时遭遇依赖冲突求助
解决Google Cloud BigQuery 3.12.0与Python 3.12的依赖冲突问题
问题背景
使用以下env.yml配置文件:
name: env-app channels: - conda-forge - defaults dependencies: - google-cloud-bigquery=3.12.0 - flask=3.0.* - python=3.12.*
执行命令micromamba env create --file environment.yml时,出现依赖冲突错误,核心原因是google-cloud-bigquery 3.12.0依赖的pandas和shapely版本未适配Python 3.12,导致环境无法创建。
错误输出如下:
conda-forge/osx-arm64 Using cache conda-forge/noarch Using cache pkgs/main/osx-arm64 No change pkgs/main/noarch No change pkgs/r/noarch No change pkgs/r/osx-arm64 No change error libmamba Could not solve for environment specs The following packages are incompatible ├─ google-cloud-bigquery 3.12.0** is installable and it requires │ ├─ pandas >=1.1.0 with the potential options │ │ ├─ pandas [1.1.3|1.1.4|...|2.0.3] would require │ │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ │ ├─ pandas [1.1.3|1.1.4|...|2.1.1] would require │ │ │ └─ python >=3.9,<3.10.0a0 , which can be installed; │ │ ├─ pandas [1.3.4|1.3.5|...|2.1.1] would require │ │ │ └─ python >=3.10,<3.11.0a0 *_cpython, which can be installed; │ │ ├─ pandas [1.3.4|1.3.5|...|2.0.3] would require │ │ │ └─ python >=3.8,<3.9.0a0 *_cpython, which can be installed; │ │ ├─ pandas [1.3.4|1.3.5|...|2.1.1] would require │ │ │ └─ python >=3.9,<3.10.0a0 *_cpython, which can be installed; │ │ ├─ pandas [1.5.1|1.5.2|...|2.1.1] would require │ │ │ └─ python >=3.11,<3.12.0a0 *_cpython, which can be installed; │ │ ├─ pandas 2.1.1 would require │ │ │ └─ python >=3.12.0rc3,<3.13.0a0 *_cpython but there are no viable options │ │ │ ├─ python 3.12.0 would require │ │ │ │ └─ python_abi 3.12.* *_cp312, which can be installed; │ │ │ └─ python 3.12.0rc3 would require │ │ │ └─ _python_rc, which does not exist (perhaps a missing channel); │ │ ├─ pandas [1.3.5|1.4.1|...|2.1.1] would require │ │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ │ └─ pandas [1.5.2|1.5.3|2.0.3|2.1.1] would require │ │ └─ python >=3.11,<3.12.0a0 , which can be installed; │ └─ shapely >=1.8.4,<2.0dev with the potential options │ ├─ shapely [1.8.4|1.8.5] would require │ │ └─ python_abi 3.10.* *_cp310, which conflicts with any installable versions previously reported; │ ├─ shapely [1.8.4|1.8.5] would require │ │ └─ python_abi 3.8.* *_cp38, which conflicts with any installable versions previously reported; │ ├─ shapely [1.8.4|1.8.5] would require │ │ └─ python_abi 3.9.* *_cp39, which conflicts with any installable versions previously reported; │ ├─ shapely 1.8.5 would require │ │ └─ python_abi 3.11.* *_cp311, which conflicts with any installable versions previously reported; │ ├─ shapely 1.8.4 would require │ │ └─ python >=3.10,<3.11.0a0 , which can be installed; │ ├─ shapely 1.8.4 would require │ │ └─ python >=3.8,<3.9.0a0 , which can be installed; │ └─ shapely 1.8.4 would require │ └─ python >=3.9,<3.10.0a0 , which can be installed; └─ python 3.12.* is not installable because there are no viable options ├─ python 3.12.0 conflicts with any installable versions previously reported; ├─ python 3.12.0, which cannot be installed (as previously explained); └─ python 3.12.0rc3, which cannot be installed (as previously explained). critical libmamba Could not solve for environment specs
解决方案
方案1:升级google-cloud-bigquery到支持Python 3.12的版本
google-cloud-bigquery 3.13.0及后续版本已适配Python 3.12,修改env.yml中的版本号:
name: env-app channels: - conda-forge - defaults dependencies: - google-cloud-bigquery>=3.13.0 - flask=3.0.* - python=3.12.*
执行micromamba env create --file environment.yml即可创建兼容环境。
方案2:降级Python到兼容版本
如果必须使用google-cloud-bigquery 3.12.0,可将Python版本降级到3.11.*(该版本与依赖的pandas、shapely版本兼容):
name: env-app channels: - conda-forge - defaults dependencies: - google-cloud-bigquery=3.12.0 - flask=3.0.* - python=3.11.*
方案3:允许包管理器自动解决依赖
移除google-cloud-bigquery的固定版本号,让micromamba自动选择与Python 3.12兼容的版本:
name: env-app channels: - conda-forge - defaults dependencies: - google-cloud-bigquery - flask=3.0.* - python=3.12.*
内容的提问来源于stack exchange,提问作者CommonSenseCode
相关产品推荐
相关产品推荐

