使用pip安装Python模块gmpy2时Wheel构建失败求助
Hey there! That build error when installing gmpy2 is super common—it happens because the library depends on three low-level system libraries that aren't installed by default. Let's walk through how to fix this step by step.
Step 1: Install Required System Dependencies
gmpy2 relies on GMP, MPFR, and MPC to compile successfully. Run the command matching your Linux distribution:
For Debian/Ubuntu-based systems (your log shows linux-x86_64 which fits this family)
sudo apt-get update sudo apt-get install libgmp-dev libmpfr-dev libmpc-dev
For RedHat/CentOS/Rocky Linux systems
# For older versions using yum sudo yum install gmp-devel mpfr-devel libmpc-devel # For newer versions using dnf sudo dnf install gmp-devel mpfr-devel libmpc-devel
Step 2: Reinstall gmpy2
Once the dependencies are in place, run the install command again:
pip install gmpy2
Alternative: Use Pre-compiled Wheels
If you still hit compile issues, try using pre-built wheels to skip the build process entirely:
pip install gmpy2 --only-binary :all:
Quick Note
Make sure you're running these commands in your active virtual environment (if you're using one) to avoid permission issues or installing to the system Python by mistake.
Pro tip: Since your log mentions Python 3.6 (
temp.linux-x86_64-3.6), double-check that your system libraries are compatible with this older Python version—most modern repos still support it, but it's worth verifying if you run into edge cases.
内容的提问来源于stack exchange,提问作者mahmoudadel

