ValueError: numpy.dtype has the wrong size, try recompiling常用的機(jī)器學(xué)習(xí)的包有:
numpy
pandas
spicy
scikit-learn
以及需要用到的作圖工具matplotlib
安裝過程:
1.numpy
sudo pip install numpy
2.安裝scipy
pip install scipy
3.安裝pandas
pip install pandas
4.安裝scikit-learn
pip install -U scikit-learn
5.安裝matplotlib
pip install matplotlib
安裝之后可以使用
pip freeze
查看已安裝的包
pip install --upgrade xxx
升級(jí)已安裝的包
遇到的問題:
問題一:
在安裝或者卸載包的時(shí)候可能會(huì)出現(xiàn)
OSError: [Errno 1] Operation not permitted:
問題主要是由于EICaption使用了Rootlees,可以理解為一個(gè)更高等級(jí)的內(nèi)核保護(hù)晴竞,系統(tǒng)會(huì)默認(rèn)鎖定/system , /sbin , /usr這三個(gè)目錄
這時(shí)候可以通過
1.重啟電腦,按command+R進(jìn)入恢復(fù)模式,點(diǎn)擊菜單【實(shí)用工具】,打開【終端】,輸入 csrutil disable
2.重啟電腦砾医,正常進(jìn)入,打開【終端】輸入 csrutil? status
同時(shí)在卸載的時(shí)候使用管理員權(quán)限
sudo pip uninstall xxx
問題二:
使用scikit-learn時(shí)出現(xiàn)
ValueError: numpy.dtype has the wrong size, try recompiling
根據(jù)網(wǎng)上的建議都是重新卸載numpy衣厘,scipy,scikit-learn然后重新安裝如蚜,其中scikit-learn使用
pip install -U numpy scipy scikit-learn
但是經(jīng)過試驗(yàn)之后問題依然存在。
這時(shí)可以使用一下途徑來解決問題:
git clone https://github.com/scikit-learn/scikit-learn
cd scikit-learn
make
sudo python setup.py install
在安裝過程中可能會(huì)出現(xiàn)
RuntimeError: Running cythonize failed!
因此可以在安裝scikit-learn之前安裝cythonize
pip install cython