成功解决打包时不能import自定义的包或库出现运行exe时No module named 缺少包
目录
解决问题
打包时不能import自定义的包或库的情况, pyinstaller打包成exe后,运行exe时No module named 缺少包
又出现
解决方法
T1、转移
直接将包移动到系统默认提取库的文件夹内
T2、采用下列方法
T3、添加路径
先查找当前导入路径,然后手动添加导入包的路径
>>> import sys
>>> sys.path
['', 'F:\Program Files\Python\Python36\python36.zip', 'F:\Program Files\Python\Python36\DLLs', 'F:\Program Files\Python\Python36\lib', 'F:\Program Files\Python\Python36', 'F:\Program Files\Python\Python36\lib\site-packages', 'F:\Program Files\Python\Python36\lib\site-packages\win32', 'F:\Program Files\Python\Python36\lib\site-packages\win32\lib', 'F:\Program Files\Python\Python36\lib\site-packages\Pythonwin']
>>>
>>> sys.path
['', 'F:\Program Files\Python\Python36\Lib\site-packages\keras_yolo3\keras-yol**', 'F:\Program Files\Python\Python36\python36.zip', 'F:\Program Files\Python\Python36\DLLs', 'F:\Program Files\Python\Python36\lib', 'F:\Program Files\Python\Python36', 'F:\Program Files\Python\Python36\lib\site-packages', 'F:\Program Files\Python\Python36\lib\site-packages\win32', 'F:\Program Files\Python\Python36\lib\site-packages\win32\lib', 'F:\Program Files\Python\Python36\lib\site-packages\Pythonwin']
>>>