Xubuntu17.10安装mlpy3.5.0遇GSL头文件缺失问题求助
Hey there, let's work through this mlpy installation issue together. The root problem here is that your compiler can't locate the GNU Scientific Library (GSL) headers and libraries correctly, even after your attempts to install GSL. Let's clean up the previous steps and do this properly:
Step 1: Clean Up Previous Messy Installs
First, let's remove any misplaced files and incomplete packages to avoid conflicts:
- Delete the manually copied GSL folders:
sudo rm -rf /usr/local/include/gsl rm -rf mlpy-3.5.0/mlpy/gsl - Uninstall any partial mlpy installs and conflicting GSL packages:
pip uninstall -y mlpy sudo apt purge -y libgsl*
Step 2: Install the Correct GSL Development Package
The key mistake earlier was installing a runtime GSL package instead of the development version, which includes the headers needed for compilation. Let's install the full, system-managed GSL dev package:
sudo apt update sudo apt install -y libgsl-dev
This package places headers in /usr/include/gsl and libraries in /usr/lib/x86_64-linux-gnu—paths that your compiler checks by default, so no extra configuration is needed.
Step 3: Reinstall mlpy Properly
Now navigate back to your extracted mlpy directory and install it correctly. Since you're using Anaconda, make sure you're in the right environment first:
- Activate your Conda environment (skip if using base):
conda activate your_environment_name - Move to the mlpy folder:
cd mlpy-3.5.0 - Install using either
setup.pyorpip(pip is more reliable for dependency handling):# Option 1: Using setup.py python setup.py build sudo python setup.py install # Option 2: Using pip (preferred) pip install .
If You Still Encounter Issues (Conda Environment Path Conflicts)
Sometimes Conda can override system library paths. If the above fails, manually specify the GSL paths using pkg-config to get the correct locations:
- Check GSL's installed paths:
pkg-config --cflags gsl # Returns header path pkg-config --libs gsl # Returns library path - Build with explicit paths:
python setup.py build_ext --include-dirs=/usr/include --library-dirs=/usr/lib/x86_64-linux-gnu --rpath=/usr/lib/x86_64-linux-gnu python setup.py install
Why Your Previous Attempts Failed
- Misplaced header files: Copying
/home/gsl/include/gslintomlpy-3.5.0/mlpy/gslcreated a nested path (mlpy/gsl/gsl/...), which didn't match the#include "gsl/gsl_sf.h"directive in the code. - Incorrect GSL package:
libgsl0ldblis a runtime library—you needlibgsl-devfor the header files required to compile mlpy. - Path typo: You ran
python setup.py build_ext --include-dirs=/home/gls/include/gls(note the typoglsinstead ofgsl), which pointed to a non-existent directory.
内容的提问来源于stack exchange,提问作者Loò

