简体   繁体   English

导入期间Scikit学习中的运行时错误

[英]Runtime error in Scikit-learn during import

I am new to Python. 我是Python的新手。 So, sorry in advance if this sounds silly but I couldn't find an understandable solution in the forum. 因此,如果这听起来很愚蠢,请您提前抱歉,但是我在论坛中找不到可理解的解决方案。 I am trying to run my programs in Pycharm and recently changed it from Python 3.5 to Python 2.7.12. 我正在尝试在Pycharm中运行程序,最近将其从Python 3.5更改为Python 2.7.12。 After doing so I have started getting the below error while importing from Scikit-learn: 这样做之后,我从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

I am using Pycharm IDE - 2016.1, Mac OS, Python 2.7.12. 我正在使用Pycharm IDE-2016.1,Mac OS,Python 2.7.12。 Please let me know how do I get around this. 请让我知道我该如何解决。

Thanks 谢谢

It looks like you're still running out of lib/python2.7/site-packages/ , per your error message. 根据您的错误消息,看来您仍然用完lib/python2.7/site-packages/ You need to configure your interpreter to use Anaconda for Python 3. If you've installed Anaconda correctly, you should be able to go to Settings -> NameOfYourProject -> Project Interpreter. 您需要配置解释器以将Anaconda用于Python3。如果正确安装了Anaconda,则应该可以转到“设置”->“ NameOfYourProject”->“项目解释器”。 Change the Interpreter to point to your Anaconda 3.x stack. 更改解释器以指向您的Anaconda 3.x堆栈。

Also, make sure you download/install Anaconda 3.x (not just Python). 另外,请确保您下载/安装Anaconda 3.x(不仅仅是Python)。 Anaconda 3 comes with the Python 3 interpreter, so you'll just need to install the most recent version and you should be able to find it in the Pycharm drop down. Anaconda 3随附了Python 3解释器,因此您只需要安装最新版本,便可以在Pycharm下拉列表中找到它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM