【发布时间】:2023-03-06 00:07:01
【问题描述】:
我一直在尝试机器学习,并且通过 anaconda 安装了 scikit-learn,但是当我尝试从 sklearn 导入时,我的解释器给了我一个 ImportError。当我尝试时
python setup.py install
在我的 site-packages/sklearn 目录中,我收到此错误:
creating build/temp.macosx-10.5-x86_64-3.5
creating build/temp.macosx-10.5-x86_64-3.5/src
creating build/temp.macosx-10.5-x86_64-3.5/src/libsvm
compile options: '-I/Users/jj/anaconda3/lib/python3.5/site-packages/numpy/core/include -c'
g++: src/libsvm/libsvm_template.cpp
clang: error: no such file or directory: 'src/libsvm/libsvm_template.cpp'
clang: error: no input files
clang: error: no such file or directory: 'src/libsvm/libsvm_template.cpp'
clang: error: no input files
我能够下载 SciPy、NumPy 和 nltk,因此不确定是否存在依赖问题。
我对 Python 包和 scikit-learn 不是很熟悉。 有谁知道这个错误是什么意思/如何进行?
【问题讨论】:
-
您下载/安装 sklearn、numpy、scipy 等的命令是什么?你能很好地导入 Numpy、Scipy 等吗?你有没有通过 pip 或 easy_install 安装过 numpy 和 scipy?
-
@NBartley 我最初安装了 miniconda,然后使用 conda 命令安装了 sklearn、numpy 和 scipy。无论我使用 miniconda 还是 anaconda,将 sklearn、numpy 等安装在具有该名称的单独文件夹中——我尝试将它们移动到系统和框架下的我的 python 库文件夹中,但这没有用。我导入 Numpy,Scipy 就好了。 (ty!)
-
“无论我使用 miniconda 还是 anaconda,都将 sklearn、numpy 等安装在具有该名称的单独文件夹中” - 这就是
conda的方式应该工作。这些模块应安装在anaconda/pkgs的子目录中。您无需移动目录或致电python setup.py install。我建议您重新安装 Anaconda/Miniconda,因为您现在拥有的可能已损坏。
标签: python numpy machine-learning installation scikit-learn