0

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?

2 Answers 2

2

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!

Sign up to request clarification or add additional context in comments.

1 Comment

2

I had the same problem and found this helped a lot:

Execute pyinstaller so you have a .spec file. Then edit the spec file with hidden_imports:

hiddenimports=['secrets','getpass','ssl','cryptography.hazmat.primitives.kdf.pbkdf2'],

Then execute as follows:

PyInstaller my_script.spec

This gave me an .exe file that works

1 Comment

With Cryptography 43, 'cryptography.x509 ' was also found to be needed. See github.com/oracle/python-oracledb/issues/401

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.