在使用Pyinstaller打包相关程序时,使用到了tensorflow-gpu。运行打包后的exe,报错:
ModuleNotFoundError: No module named 'tensorflow.python._pywrap_tensorflow_internal'
Failed to load the native TensorFlow runtime.
解决方法:在dist目标路径中创建文件夹:“tensorflow/python”,然后剪切dist目录下的“_pywrap_tensorflow_internal”至该文件夹,问题解决。
前一个问题解决掉之后,又有了新的问题:
AttributeError: type object 'sklearn.metrics.pairwise_fast.array' has no attribute '__reduce_cython__'
这里我查找了网上很多资料,没有办法解决。
采坑踩久了就会有特别的想法:我把dist路径下的sklearn删除,然后运行程序。缺少哪个Module,就去python 文件夹下拷贝对应的文件夹,最终解决了该问题。关键的决方法是不再使用*.pyd文件,而直接使用*.py文件,从而避免了莫名其妙的错误。