小编Dar*_*gic的帖子

由pyinstaller创建的exe文件,在运行时找不到自定义模块

我创建了两个python文件,目录/文件关系如下:

mytest---
     |---mycommon.py
     |---myMainDir---
                     |----myMain.py
Run Code Online (Sandbox Code Playgroud)

在mycommon.py中:

def myFunc(a):
    ...
Run Code Online (Sandbox Code Playgroud)

在myMain.py中:

import sys
sys.path.append(os.path.join(os.path.dirname(os.path.abspath('__file__')), '..'))
import mycommon.py
mycommon.myFunc("abc")
Run Code Online (Sandbox Code Playgroud)

然后我使用pyinstaller创建了exe:

pyinstall.py -F mytest\myMainDir\myMain.py
Run Code Online (Sandbox Code Playgroud)

MyMain.exe已创建,但运行时会告诉无法找到mycommon模块.

python python-2.6 pyinstaller python-2.7 python-3.x

9
推荐指数
1
解决办法
2万
查看次数

标签 统计

pyinstaller ×1

python ×1

python-2.6 ×1

python-2.7 ×1

python-3.x ×1