Amazon SageMaker Notebook中LightFM库安装失败求助
解决Amazon SageMaker Notebook中LightFM安装失败问题
此前在Amazon SageMaker Notebook中使用LightFM库一直正常,但从昨日开始,执行pip install lightfm时无法完成安装,出现以下错误:
Building wheels for collected packages: lightfm Building wheel for lightfm (setup.py) ... error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [176 lines of output] /home/ec2-user/anaconda3/envs/python3/lib/python3.10/site-packages/setuptools/dist.py:775: UserWarning: Usage of dash-separated 'description-file' will not be supported in future versions. Please use the underscore name 'description_file' instead ... ... ... In file included from /home/ec2-user/anaconda3/envs/python3/include/python3.10/unicodeobject.h:1046:0, from /home/ec2-user/anaconda3/envs/python3/include/python3.10/Python.h:83, from lightfm/_lightfm_fast_openmp.c:20: /home/ec2-user/anaconda3/envs/python3/include/python3.10/cpython/unicodeobject.h:551:42: note: declared here Py_DEPRECATED(3.3) PyAPI_FUNC(PyObject*) PyUnicode_FromUnicode( ^~~~~~~~~~~~~~~~~~~~~ error: command '/usr/bin/gcc' failed with exit code 1 [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: legacy-install-failure × Encountered error while trying to install package. ╰─> lightfm note: This is an issue with the package mentioned above, not pip. hint: See above for output from the failure.
已尝试以下方法但均无效:
pip install --upgrade pippip install --upgrade wheelpip install --upgrade setuptoolspip install Cmakepip install requests --no-dependencies
可行解决方案
1. 切换兼容的Python版本
LightFM官方对Python 3.10的支持不完善,建议切换到Python 3.9环境:
conda create -n lightfm_env python=3.9 -y conda activate lightfm_env pip install lightfm
2. 使用conda安装预编译包
避免源码编译,直接通过conda安装预编译好的LightFM:
conda install -c conda-forge lightfm -y
若需要指定版本,可执行:
conda install -c conda-forge lightfm=1.17 -y
3. 安装系统编译依赖
如果必须从源码编译,先安装完整的编译工具链:
sudo yum install gcc gcc-c++ make -y pip install lightfm
4. 降级setuptools版本
新版setuptools与LightFM的旧版setup.py存在兼容性问题,尝试降级:
pip install setuptools==58.0.4 pip install lightfm
内容的提问来源于stack exchange,提问作者DS Park
相关产品推荐
相关产品推荐

