我是Python新手。所以,如果这听起来很傻,请提前抱歉,但我无法在论坛中找到可理解的解决方案。我试图在Pycharm中运行我的程序,最近将它从Python 3.5更改为Python 2.7.12。这样做后,我从Scikit-learn导入时开始出现以下错误:
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/__check_build/__init__.py", line 46, in <module>
raise_build_error(e)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/__check_build/__init__.py", line 41, in raise_build_error
%s""" % (e, local_dir, ''.join(dir_content).strip(), msg))
ImportError: dynamic module does not define init function (init_check_build)
___________________________________________________________________________
Contents of /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/sklearn/__check_build:
__init__.py __init__.pyc _check_build.so
setup.py setup.pyc
___________________________________________________________________________
It seems that scikit-learn has not been built correctly.
If you have installed scikit-learn from source, please do not forget
to build the package before using it: run `python setup.py install` or
`make` in the source directory.
If you have used an installer, please check that it is suited for your
Python version, your operating system and your platform.
Process finished with exit code 1
我正在使用Pycharm IDE - 2016.1,Mac OS,Python 2.7.12。请让我知道如何解决这个问题。
由于
答案 0 :(得分:1)
根据您的错误消息,您似乎仍然没有使用lib/python2.7/site-packages/
。您需要将解释器配置为使用Anaconda for Python 3.如果您已正确安装Anaconda,您应该可以转到设置 - &gt; NameOfYourProject - &gt;项目口译员。将解释器更改为指向Anaconda 3.x堆栈。
另外,请确保下载/安装Anaconda 3.x(不仅仅是Python)。 Anaconda 3附带了Python 3解释器,因此您只需要安装最新版本,您就可以在Pycharm下拉列表中找到它。