I am trying to build python source code using pyinstaller
. Once Building is successful I am running the binary file. Once I run the binary file I am getting the following ImportError
:
PyUtils.CouchbaseClient", line 13, in <module>
ImportError: No module named couchbase
But couchbase
is already installed and I am able to run the original Python source code without any import errors. After converting into the binary I am getting ImportError.
Any help would be really appreciated.
Since your program dynamically imports couchbase, pyinstaller can't detect that it is required, as specified in the documentation:
Another section of the documentation extends on this issue and suggests some workarounds for dealing with this scenario:
Therefore, you need to explicitly ask pyinstaller to include the required module during the build process. It seems that the easiest way to do so is with the
--hidden-import
argument:Thus, please add the following argument when building the application:
--hidden-import=couchbase
However, once PyInstaller detects that
couchbase
is required, running the resulting executable fails with anImportError
:This answer describes what should be done in order to resolve it.