解决FastAPI与Pydantic版本不兼容及python-jobspy安装依赖循环问题
Hey there, I’ve run into this exact kind of dependency mess before—let’s get this sorted out for you!
The core problem here is a version clash: your globally installed FastAPI 0.70.0 requires Pydantic < 2.0, but python-jobspy needs Pydantic 2.x. Trying to install jobspy globally will keep overwriting your Pydantic version and triggering that frustrating conflict loop.
The safest and most reliable fix is using a virtual environment (which you already thought of!)—it isolates your project’s dependencies so they don’t interfere with your global packages. Here’s step-by-step what to do:
Create a virtual environment
Open your terminal, navigate to the folder where you want to work on your jobspy project, then run:# Name it whatever you want, 'jobspy-env' is just an example python -m venv jobspy-envActivate the virtual environment
- On Windows (Command Prompt):
jobspy-env\Scripts\activate.bat - On Windows (PowerShell):
jobspy-env\Scripts\Activate.ps1 - On macOS/Linux:
source jobspy-env/bin/activate
You’ll see the environment name pop up in your terminal prompt once it’s active—this means you’re working in the isolated space now.
- On Windows (Command Prompt):
Install python-jobspy in the virtual environment
Now run your install command again:pip install -U python-jobspySince we’re in a clean environment, pip will install all the correct dependencies (including Pydantic 2.x) without conflicting with your global FastAPI setup.
If you really don’t want to use a virtual environment, another option is upgrading your global FastAPI to a version that supports Pydantic 2.x (FastAPI 0.95.0 and above work with Pydantic 2). But this might break other projects relying on your older FastAPI version, so the virtual environment approach is way safer.
Just to recap the error you encountered (so we’re aligned on the issue):
Successfully uninstalled pydantic-1.10.21
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
fastapi 0.70.0 requires pydantic!=1.7,!=1.7.1,!=1.7.2,!=1.7.3,!=1.8,!=1.8.1,<2.0.0,>=1.6.2, but you have pydantic 2.10.6 which is incompatible.
Successfully installed pydantic-2.10.6
This happens because pip is trying to satisfy jobspy’s requirements, but your global FastAPI is locked to an older version that can’t work with Pydantic 2.x. The virtual environment avoids this entirely by giving jobspy its own independent set of packages.
备注:内容来源于stack exchange,提问作者Chaldovich Centa

