如題
我在虛擬環境中安裝的pyinstaller會一直往虛擬環境外面的site-package抓東西
大致上在 10445 INFO: Looking for dynamic libraries 之後
會列出一大堆路徑
然後就可以看到pyinstaller開始往奇怪的路徑上抓東西
另外,我用Auto-py-to-exe去抓額外檔案時,發現虛擬環境中連matplotlib都找不到
打包完的檔案用cmd去執行也是顯示沒有matplotlib
問gpt說是在程式裡面用sys先砍光路徑後新增路徑
可是這樣做又有別的問題......
之後試著用hidden import的方式把抓不到的matplotlib和nanoscope這兩個抓進去
結果用cmd運行執行檔的結果如下:
C:\Users\User\Desktop\myenv\dist>t
Traceback (most recent call last):
File "t.py", line 6, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "nanoscope\__init__.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "nanoscope\files\__init__.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "nanoscope\files\base.py", line 11, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 385, in exec_module
File "nanoscope\dll.py", line 81, in <module>
File "nanoscope\dll.py", line 38, in _load
File "os.py", line 1117, in add_dll_directory
FileNotFoundError: [WinError 3] 系統找不到指定的路徑。:
'C:\\Users\\User\\AppData\\Local\\Temp\\_MEI149682\\nanoscope\\Lib\\64bit'
[24128] Failed to execute script 't' due to unhandled exception!
是有些site-package不該抱持能夠用pyinstaller去包裝的希望嗎?