V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
timerring
V2EX  ›  Python

pip 怎么解决两个第三方依赖库的版本冲突的问题

  •  
  •   timerring · 4 天前 · 1443 次点击

    如题,俩库都不是自己写的:

    The conflict is caused by:
        google-genai 0.0.1 depends on pydantic<3.0.0dev and >=2.0.0
        fastapi 0.88.0 depends on pydantic!=1.7, !=1.7.1, !=1.7.2, !=1.7.3, !=1.8, !=1.8.1, <2.0.0 and >=1.6.2
    

    google-genai 是我要装的库,到 initial 的 0.0.1 版本也是 pydantic>=2.0.0

    另一个库是我要装的核心库,它从第一版就只要求 fastapi 0.88.0 ,对应要求则是 pydantic<2.0.0

    这种情况老哥们有什么解决的办法吗🤔

    12 条回复    2025-04-05 23:18:43 +08:00
    iyaozhen
        1
    iyaozhen  
       4 天前
    我理解是解决不了 只能让你另一个核心库升级
    renmu
        2
    renmu  
       4 天前 via Android
    找找老版本,或者强制装试试,不一定用的 api 刚好被改了,不然就只能手动了。。
    InDom
        3
    InDom  
       4 天前
    Docker
    Cooky
        4
    Cooky  
       4 天前
    conda
    Insolitude
        5
    Insolitude  
       4 天前 via Android
    有个邪道路子,手动下载 whl 文件,然后用 wheel 解压,更改依赖版本,然后重新打包安装,最后祈祷不会报错。当然也可以解压了改代码,更新到新版本
    Vegetable
        6
    Vegetable  
       4 天前
    很难解决,fork 一下另一个库,把 fastapi 升级一下。
    ClericPy
        7
    ClericPy  
       2 天前
    干过类似的,直接猴子补丁篡改人家源码或者挂补丁

    反正早年间不重复造轮子,晚年以后尽量不引用第三方的玩意,依赖冲突太麻烦了,很多 1.0 以前版本的更慎重,毕竟没 stable 的版本意味着一两个月以后就升级的面目全非的了
    iorilu
        8
    iorilu  
       2 天前
    重搞个虚拟环境, 装你要的版本

    然后手动复制覆盖老版本
    tomczhen
        9
    tomczhen  
       2 天前
    要么维护者升级,要么自己 fork 一份代码从源码安装,有冲突的代码还需要修复。
    jamos
        10
    jamos  
       2 天前
    逐步提高 fastapi 版本,或者降低 google-genai 版本
    momocraft
        11
    momocraft  
       2 天前
    pydantic 被太多东西依赖了 不如用新的 fastapi
    Martin123123
        12
    Martin123123  
       1 天前
    优先建议 fastapi 升级,pydantic 2.0 可以手动该代码兼容历史的旧模块
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2951 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 21ms · UTC 14:34 · PVG 22:34 · LAX 07:34 · JFK 10:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.