pip install pydantic==1.10
执行上面的指令安装 1.10 系列版本的 pydantic即可。
开源库的各种版本依赖关系是一个非常容易出错的点。
例如如果遇到这样的报错:
友情链接:ACEJoy
pf -v
Traceback (most recent call last):
File "C:\anaconda3\lib\runpy.py", line 196, in _run_module_as_main
return _run_code(code, main_globals, None,
File "C:\anaconda3\lib\runpy.py", line 86, in _run_code
exec(code, run_globals)
File "C:\Users\linke\AppData\Roaming\Python\Python310\Scripts\pf.exe\__main__.py", line 4, in <module>
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\promptflow\__init__.py", line 14, in <module>
from ._sdk._pf_client import PFClient
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\promptflow\_sdk\_pf_client.py", line 15, in <module>
from .operations import RunOperations
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\promptflow\_sdk\operations\__init__.py", line 7, in <module>
from ._run_operations import RunOperations
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\promptflow\_sdk\operations\_run_operations.py", line 29, in <module>
from promptflow._sdk.operations._local_storage_operations import LocalStorageOperations
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\promptflow\_sdk\operations\_local_storage_operations.py", line 34, in <module>
from promptflow.batch._result import BatchResult
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\promptflow\batch\__init__.py", line 6, in <module>
from ._base_executor_proxy import AbstractExecutorProxy, APIBasedExecutorProxy
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\promptflow\batch\_base_executor_proxy.py", line 19, in <module>
from promptflow.executor._result import AggregationResult, LineResult
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\promptflow\executor\__init__.py", line 6, in <module>
from .flow_executor import FlowExecutor
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\promptflow\executor\flow_executor.py", line 22, in <module>
from promptflow._core.openai_injector import inject_openai_api
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\promptflow\_core\openai_injector.py", line 11, in <module>
import openai
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\openai\__init__.py", line 8, in <module>
from . import types
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\openai\types\__init__.py", line 5, in <module>
from .edit import Edit as Edit
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\openai\types\edit.py", line 6, in <module>
from .._models import BaseModel
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\openai\_models.py", line 18, in <module>
import pydantic
File "pydantic\__init__.py", line 2, in init pydantic.__init__
File "pydantic\dataclasses.py", line 43, in init pydantic.dataclasses
# | <blank> | No action: no method is added. |
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\pydantic\class_validators.py", line 2, in <module>
from ._migration import getattr_migration
File "C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\pydantic\_migration.py", line 4, in <module>
from .version import version_short
ImportError: cannot import name 'version_short' from 'pydantic.version' (C:\Users\linke\AppData\Roaming\Python\Python310\site-packages\pydantic\version.cp310-win_amd64.pyd)