Ubuntu 16.04下安装Vowpal Wabbit Python Wrapper失败求助
Hey there, let's work through this LTO version conflict you're hitting when trying to install the Vowpal Wabbit Python wrapper. That error (lto1: fatal error: bytecode stream generated with LTO version 6.0 instead of the expected 4.1) happens because of a mismatch between the compiler used to build your Boost libraries (likely from Anaconda) and your system's default g++ 5.4.0. Here's how to fix it:
Step 1: Confirm the Compiler Conflict
First, let's verify the root cause:
- Check your system's g++ version:
You should seeg++ --versiong++ (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609(LTO version 4.1 for this release). - Check if Anaconda has its own gcc/g++ installed:
If you see a newer version (like gcc 7+), that's the problem—Anaconda's Boost was compiled with this newer compiler, which uses LTO version 6.0, but your system's g++ can't read that bytecode.conda list gcc
Step 2: Force Pip to Use System Compiler
The simplest fix is to tell pip to use your system's g++ 5.4.0 instead of Anaconda's compiler. Run these commands in your terminal:
# Set environment variables to point to system compilers export CC=gcc-5 export CXX=g++-5 # Install vowpalwabbit with no cache to avoid using previous failed builds pip3 install vowpalwabbit --no-cache-dir
Step 3: Compile from Source (If Step 2 Fails)
If the above doesn't work, compile Vowpal Wabbit from source and explicitly specify the system compiler:
- Clone the Vowpal Wabbit repo:
git clone https://github.com/VowpalWabbit/vowpal_wabbit.git cd vowpal_wabbit - Create a build directory and run CMake with system compilers:
mkdir build && cd build cmake .. -DCMAKE_C_COMPILER=gcc-5 -DCMAKE_CXX_COMPILER=g++-5 -DPYTHON_EXECUTABLE=$(which python3) - Compile and install the core library:
make -j$(nproc) sudo make install - Install the Python wrapper:
cd ../python pip3 install .
Step 4: Optional: Isolate from Anaconda
If you still run into issues, try temporarily deactivating your Anaconda environment to use only system dependencies:
conda deactivate # Repeat the pip install or source compile steps here
Why This Works
LTO (Link Time Optimization) generates bytecode that's specific to the compiler version. Anaconda's Boost libraries were built with a newer g++ (which uses LTO 6.0), but your system's g++ 5.4.0 expects LTO 4.1. By forcing the use of your system's compiler during the Vowpal Wabbit build, you ensure compatibility with the compiler version that will link against the libraries.
内容的提问来源于stack exchange,提问作者Sergijjj

