安装psycopg2时python setup.py bdist_wheel执行失败求助
安装psycopg2失败的解决方案
错误信息
PS D:\Visualalize_data> pip3 install psycopg2 Collecting psycopg2 Using cached psycopg2-2.9.5.tar.gz (384 kB) Preparing metadata (setup.py) ... done Building wheels for collected packages: psycopg2 Building wheel for psycopg2 (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [22 lines of output] D:\Python\Lib\site-packages\setuptools\config\setupcfg.py:508: SetuptoolsDeprecationWarning: The license_file parameter is deprecated, use license_files instead. warnings.warn(msg, warning_class) running bdist_wheel running build g2._psycopg' extension error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/ [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for psycopg2 Running setup.py clean for psycopg2 Failed to build psycopg2 Installin running build legacy-install-failure × Encountered error while trying to install package. ╰─> psycopg2 note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.
已尝试操作
pip install nes-py --no-cache-dirpip install --upgrade pip setuptools wheel
系统环境
- Windows 10
- Python 3.10.2 64位
- Visual Studio Code
有效解决方法
方法1:安装编译依赖
安装包含**Desktop development with C++**工作负载的Microsoft C++ Build Tools,确保勾选MSVC v142+工具链、Windows 10 SDK等核心组件。安装完成后重启终端,再次执行:
pip install psycopg2
方法2:安装预编译二进制包(推荐)
直接安装预编译好的psycopg2-binary包,无需本地编译环境,执行命令:
pip install psycopg2-binary
内容的提问来源于stack exchange,提问作者Nitin Kushwaha
相关产品推荐
相关产品推荐

