简体   繁体   English

如何将train_test_split导入pyinstaller可执行文件?

[英]How can i import train_test_split to pyinstaller executable file?

Hi everyone i had some problems, but while i am solving them new ones are coming. 大家好,我遇到了一些问题,但是当我解决它们时,新问题就来了。 For example after i have converted the py file to exe file i was getting No module named "numpy.random.common" error so i solved this with --hidden-import = "...". 例如,在我将py文件转换为exe文件之后,我得到了没有名为“ numpy.random.common”的模块错误,因此我使用--hidden-import =“ ...”解决了此问题。 In my program i am using train_test_split library to split the data to train and test sets. 在我的程序中,我正在使用train_test_split库将数据拆分为训练集和测试集。 When i open the exe file i can not do this so i recognized that in the dist file there is a sklearn file but in the sklearn file there is no model_selection file so i think my problem is that,how can i import the sklearn.model_selection.train_test_split to pyinstaller exe ? 当我打开exe文件时,我无法执行此操作,因此我认识到dist文件中存在sklearn文件,但sklearn文件中没有model_selection文件,因此我认为我的问题是,我该如何导入sklearn.model_selection .train_test_split到pyinstaller exe吗? I have tried --hidden-import="sklearn.model_selection.train_test_split" but it didn't work. 我已经尝试过--hidden-import =“ sklearn.model_selection.train_test_split”,但是没有用。 Thank you. 谢谢。

I have found the solution, I have defined from sklearn.model_selection import train_test_split in the def ..(): then i have removed it, and write on the top of the main code. 我找到了解决方案,我已经从def ..()中的sklearn.model_selection import train_test_split定义了:然后我将其删除,并写在主要代码的顶部。 When i convert the py file it gave me an error like : 当我转换py文件时,它给了我类似的错误:

ModuleNotFoundError: No module named 'sklearn.neighbors.ball_tree.NeighborsHeap'

i write it like --hidden-import="sklearn.neighbors.ball_tree.NeighborsHeap" so it is solved. 我把它写成--hidden-import =“ sklearn.neighbors.ball_tree.NeighborsHeap”这样就解决了。

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

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