‘No module named util’ error when using pyinstaller

上次打包 python script 時很順利,一下次就過了。這次遇到加了 hidden import  還是無效。

Error Message:

ImportError: No module named utils


在程式碼裡移掉 APNS 相關代碼後,換成 tornado 錯誤:

Traceback (most recent call last):
 File "mdmserver.py", line 40, in <module>
 File "app/thinkingweb.py", line 41, in __init__
 File "site-packages/tornado/web.py", line 1910, in __init__
 File "site-packages/tornado/web.py", line 1785, in __init__
 File "site-packages/tornado/routing.py", line 363, in __init__
 File "site-packages/tornado/routing.py", line 288, in __init__
 File "site-packages/tornado/routing.py", line 300, in add_rules
 File "site-packages/tornado/routing.py", line 413, in __init__
 File "site-packages/tornado/util.py", line 171, in import_object
ImportError: No module named controller
[16436] Failed to execute script mdmserver

Ohoh 天呀, 程式跑在CentOS 好像問題很多.

耶!最後還是解決了,解法還是在 hiddenimports,把我自己的 source code 加入到 hiddenimports 裡就可以了。

ex:

hiddenimports=['tornado','myapp','myapp.controller','myapp.dbo','myapp.lib','mysql'],

 

 

相關的bug:

ImportError with statsmodels #2183
https://github.com/pyinstaller/pyinstaller/issues/2183

ImportError: No module named UserList #2327
https://github.com/pyinstaller/pyinstaller/issues/2327

 

相關文章

寫留言

你的電子郵件位址並不會被公開。 必要欄位標記為 *