Reputation: 143
I converted a .py file to .exe using pyinstaller and made a copy of the whole directory on another machine (same version of OS). 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.
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? Is there a fix for this or the .exe is meant to be run on the developer machine only?
Just a side info:
user1
machine do not have python installedIn this .spec
file
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?
Update:
ModuleNotFoundError
can be solved by using --hiddenimport
as mentioned in the answer accepted.Upvotes: 0
Views: 1314
Reputation: 108
type pyinstaller app.py --hiddenimport=pandas._libs.tslibs.offsets
when building the app
since you posted the spec file... you can put this in and just use 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)
Upvotes: 1