Issue
I get the following error when running an executable created with PyInstaller. It relates to the module oracledb.
Traceback (most recent call last): File "my_script.py", line 1, in
File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module File "oracledb/init.py", line 38, in
File "PyInstaller/loader/pyimod03_importers.py", line 495, in exec_module File "oracledb/connection.py", line 45, in
File "src/oracledb/base_impl.pyx", line 47, in init oracledb.base_impl ModuleNotFoundError: No module named 'secrets' [23464] Failed to execute script 'my_script' due to unhandled exception!
Python 3.6
From this post I understand that Python 3.6 is a dependency.
In our environment we have both Python 3.6.8 and Python 2.7
Build with Python3
Based on comments from this post, I then tried the following command to build my executable:
python3 -m PyInstaller -F my_script.py
I still get the same error.
I suspect it has something to do with the 2 versions of Python, but I do not know how to get around it. Does anyone have some advise for me please?
Solution
The oracledb module uses Cython for its base layer, which means that the modules it imports are not going to be known to PyInstaller. These modules can be found in src/oracledb/*.pyx. You can tell PyInstaller about them, or you can also just copy/paste the imports into a Python module that you include in my_script.py
. I don't know PyInstaller well enough to be able to tell you how to do the first option, but I'm sure its documentation will get you going!
Answered By - Anthony Tuininga
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.