2016-07-29 16 views
0

我是Python新手。所以,提前抱歉,如果這聽起來很愚蠢,但我無法在論壇中找到可以理解的解決方案。我試圖在Pycharm中運行我的程序,並最近將其從Python 3.5更改爲Python 2.7.12。這樣做之後,我已經開始提示以下錯誤:在從進口Scikit學習:導入期間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。請讓我知道如何解決這個問題。

感謝

回答

1

它看起來像你還在運行的lib/python2.7/site-packages/,按您的錯誤消息。你需要配置你的解釋器來使用Python 3的Anaconda。如果你已經正確安裝了Anaconda,你應該可以進入Settings - > NameOfYourProject - > Project Interpreter。將解釋器更改爲指向您的Anaconda 3.x堆棧。

此外,請確保您下載/安裝Anaconda 3.x(不只是Python)。 Anaconda 3帶有Python 3解釋器,所以你只需要安裝最新版本,你應該可以在Pycharm下拉菜單中找到它。

+0

是的我已經嘗試了所有,但Python 3 scipy,因爲我使用一個實施的項目作爲一個庫在Python 2.7中實現,它會導致問題,並引發運行時錯誤。所以我已經用Python 2.7切換到Canopy IDE。 –

+0

感謝您的幫助。 –