[英]Can PyInstaller exe file be distributed?
I converted a.py file to.exe using pyinstaller and made a copy of the whole directory on another machine (same version of OS).我使用 pyinstaller 将 a.py 文件转换为 .exe,并在另一台机器(相同版本的操作系统)上复制了整个目录。 What happen is that when I run it, it will prompt some errors.
发生的是,当我运行它时,它会提示一些错误。
developer1
is the machine that developed the script, user1
is the machine where I distribute the program to. developer1
是开发脚本的机器, user1
是我将程序分发到的机器。
C:\Users\user1\Downloads\MyApp\dist\app>app.exe
c:\users\developer1\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py:493: MatplotlibDeprecationWarning:
The MATPLOTLIBDATA environment variable was deprecated in Matplotlib 3.1 and will be removed in 3.3.
Traceback (most recent call last):
File "pandas\__init__.py", line 32, in <module>
File "c:\users\developer1\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
File "pandas\_libs\__init__.py", line 3, in <module>
File "c:\users\developer1\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
File "pandas\_libs\tslibs\__init__.py", line 3, in <module>
File "pandas\_libs\tslibs\c_timestamp.pxd", line 7, in init pandas._libs.tslibs.conversion
File "pandas\_libs\tslibs\c_timestamp.pyx", line 1, in init pandas._libs.tslibs.c_timestamp
File "pandas\_libs\tslibs\tzconversion.pyx", line 1, in init pandas._libs.tslibs.tzconversion
File "pandas\_libs\tslibs\timedeltas.pyx", line 1, in init pandas._libs.tslibs.timedeltas
ModuleNotFoundError: No module named 'pandas._libs.tslibs.offsets'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "app.py", line 6, in <module>
File "c:\users\developer1\appdata\local\programs\python\python38-32\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
File "pandas\__init__.py", line 36, in <module>
ImportError: C extension: No module named 'pandas._libs.tslibs.offsets' not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace --force' to build the C extensions first.
[10460] Failed to execute script app
I checked the .spec
file and found out that the pathex
path is actually the developer machine path, I believe this is actually causing all these errors?我检查了
.spec
文件,发现pathex
路径实际上是开发人员机器路径,我相信这实际上是导致所有这些错误的原因吗? Is there a fix for this or the.exe is meant to be run on the developer machine only?是否有解决此问题的方法,或者 .exe 只能在开发人员机器上运行?
Just a side info:只是一个侧面信息:
user1
machine do not have python installed user1
机器没有安装 python In this .spec
file在这个
.spec
文件中
a = Analysis(['app.py'],
pathex=['C:\\Users\\developer1\\App1'],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
Do I need bother about the pathex
being the path of developer machine?我需要担心
pathex
是开发者机器的路径吗?
Update:更新:
ModuleNotFoundError
can be solved by using --hiddenimport
as mentioned in the answer accepted.ModuleNotFoundError
可以通过使用--hiddenimport
来解决,如接受的答案中所述。 type pyinstaller app.py --hiddenimport=pandas._libs.tslibs.offsets
when building the app构建应用程序时键入
pyinstaller app.py --hiddenimport=pandas._libs.tslibs.offsets
since you posted the spec file... you can put this in and just use pyinstaller app.spec
既然您发布了规范文件...您可以将其放入并使用
pyinstaller app.spec
a = Analysis(['app.py'],
pathex=['C:\\Users\\developer1\\App1'],
binaries=[],
datas=[],
hiddenimports=['pandas._libs.tslibs.offsets'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.