python3.8中關(guān)于sklearn問題(win10)
python3.8中sklearn問題(win10)及pip 安裝sklearn
小編在第一次裝sklearn庫時(shí),發(fā)生了
import error cannot import name ‘__check_build’ from partially initialized module 'sklear的報(bào)錯(cuò)
在網(wǎng)上也找了很多答案,發(fā)現(xiàn)都不是很適合自己。
反而越搞越麻煩,下面小編來介紹一下本小編的解決辦法。(小編的操作環(huán)境是win10,python3.8)
解決辦法
1、在cmd中一個(gè)一個(gè)刪除python中的numpy、scipy、matplotlib、sklearn、scikit-learn庫。
操作辦法如下。
pip uninstall numpy pip uninstall scipy pip uninstall matplotlib pip uninstall sklearn pip uninstall scikit-learn
在cmd中操作(有Anaconda3的就在Anaconda Prompt中進(jìn)行),要一個(gè)一個(gè)來,不要急。

2、然后再重新裝numpy、scipy、matplotlib、sklearn、scikit-learn庫。
安裝順序最好和小編一樣。
一般不用當(dāng)心版本問題,因?yàn)?.8是目前最新的,他回給你自動(dòng)裝適合你版本的。
不用你去https://www.lfd.uci.edu/~gohlke/pythonlibs/#scikit-learn
中去找sklearn等等庫,并且那里下載速度如龜爬,如果你有VPN的話結(jié)果可能就不一樣。
pip install --index-url https://mirrors.aliyun.com/pypi/simple/ numpy pip install --index-url https://mirrors.aliyun.com/pypi/simple/ scipy pip install --index-url https://mirrors.aliyun.com/pypi/simple/ matplotlib pip install --index-url https://mirrors.aliyun.com/pypi/simple/ sklearn
如果直接用pip install numpy 的辦法,很容易出現(xiàn)time out的時(shí)間超時(shí)報(bào)錯(cuò)并且速度又慢,我這里是用阿里云的鏡像,速度剛剛的。

3、就這樣就ok了,你可以重啟一下編輯器試試看。
一個(gè)sklearn和tensorflow的bug
bug如下
“/usr/local/lib/python3.8/site-packages/sklearn/__check_build/init.py”, line 44, in
from ._check_build import check_build # noqa
ImportError: dlopen: cannot load any more object with static TLSDuring handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “CNN-meme-motifs.py”, line 5, in
import lib.graphprot_dataloader
File “/home/RNAonGraph/lib/graphprot_dataloader.py”, line 7, in
from sklearn.model_selection import KFold
File “/usr/local/lib/python3.8/site-packages/sklearn/init.py”, line 81, in
from . import __check_build # noqa: F401
File “/usr/local/lib/python3.8/site-packages/sklearn/__check_build/init.py”, line 46, in
raise_build_error(e)
File “/usr/local/lib/python3.8/site-packages/sklearn/__check_build/init.py”, line 31, in raise_build_error
raise ImportError("""%s
ImportError: dlopen: cannot load any more object with static TLSContents of /usr/local/lib/python3.8/site-packages/sklearn/_check_build:
check_build.cpython-38-x86_64-linux-gnu.so__pycache init.py
setup.pyIt 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.
源代碼
import os os.environ[‘TF_CPP_MIN_LOG_LEVEL'] = ‘3' import numpy as np import tensorflow as tf import lib.graphprot_dataloader from Model.Joint_MRT import JMRT from lib.general_utils import Pool import multiprocessing as mp import matplotlib.pyplot as plt import subprocess
bug原因及修復(fù)
原因暫時(shí)難以解釋,解決辦法是調(diào)整tensorflow和sklearn的import順序
總結(jié)
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
相關(guān)文章
使用Python輕松實(shí)現(xiàn)裁剪PDF并導(dǎo)出為圖片
在日常工作中,處理 PDF 文件是非常常見的需求,本文將介紹如何使用 Python 裁剪 PDF 頁面,以及如何將裁剪后的 PDF 導(dǎo)出為圖片,感興趣的小伙伴可以了解下2025-10-10
pytorch?cuda安裝報(bào)錯(cuò)的解決方法
這篇文章主要給大家介紹了關(guān)于pytorch?cuda安裝報(bào)錯(cuò)的解決方法,文中通過圖文介紹的非常詳細(xì),對(duì)大家學(xué)習(xí)或者使用Pytorch具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2023-01-01
python爬蟲把url鏈接編碼成gbk2312格式過程解析
這篇文章主要介紹了python爬蟲把url鏈接編碼成gbk2312格式過程解析,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-06-06
Python?reflect單例模式反射各個(gè)函數(shù)
這篇文章主要介紹了Python?reflect單例模式反射各個(gè)函數(shù),文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值需要的小伙伴可以參考一下2022-06-06
Python連接Hadoop數(shù)據(jù)中遇到的各種坑(匯總)
這篇文章主要介紹了Python連接Hadoop數(shù)據(jù)中遇到的各種坑,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-04-04

