1

I’m trying to compile a small python file which sends email based on the yagmail library, which itself relies on the keyring library.

Compiling works fine. Executing with dry-run options works fine. However, when I actually try it, it prompts for the password (as the yagmail library normally does), but once the password entered, it comes back with an error telling me that there was no keyring backend found.

Obviously, there is a keyring backend (on Windows it’s Credentials manager I believe) and it works fine when I use the same program in the python form using the python runtime.

How can I package a keyring backend in the exe file using Nuitka (or pyinstaller, for that matter)?

Louis.vgn
  • 149
  • 1
  • 1
  • 9

1 Answers1

-1

I'm not familiar with keyring, but here are a few suggestions on getting outside code/files to work with Nuitka.

  1. Test your code using normal python processes. Don't proceed to Nuitka until everything is working.
  2. Compile your code using Nuitka without --standalone or --onefile options. (I assume this is what you were referring to as a dry run option.)
  3. Test resulting .bin or .exe
  4. Compile your code with --standalone option.
  5. Test resulting .bin or .exe. Make sure you are testing the new file in the .dist folder, not the file you tested in step 3.

If your test results from steps 3 and 5 are different, you are likely not properly including all necessary files. You can manually copy and paste files into the .dist folder, or you can use the following Nuitka options to have them added at the time of the build.

--include-data-files=/AbsolutePathToCurrentFile/file.txt=relativePathInDistFolder/file.txt
--include-data-dir=/AbsolutePathToCurent/myDirectory=relativePathInDistFolder/myDirectory
--include-module=myModule
--include-package=myPackage

If you have absolute file paths for non-py files in your code, you will probably need to modify them to look at the copy in the .dist folder.

MatCat
  • 19
  • 5
  • This answer looks like it was generated by an AI (like ChatGPT), not by an actual human being. You should be aware that [posting AI-generated output is officially **BANNED** on Stack Overflow](https://meta.stackoverflow.com/q/421831). If this answer was indeed generated by an AI, then I strongly suggest you delete it before you get yourself into even bigger trouble: **WE TAKE PLAGIARISM SERIOUSLY HERE.** Please read: [Why posting GPT and ChatGPT generated answers is not currently allowed](https://stackoverflow.com/help/gpt-policy). – tchrist Jul 15 '23 at 21:00
  • @MatCat I don't get it - You seem to have the expertise in Nuitka to answer this on your own, but it really does seem likely that you used an AI tool here (I'm *thinking*, but not sure, that it is GPT4-based). As mentioned, *if* you used AI in any way here, I recommend deleting this one for now, since it is currently counter to site policy. That said, [worth a read](https://meta.stackexchange.com/a/389675/902710) since if this was disclosed and reworded, I would likely support it as a responsible use of AI here. – NotTheDr01ds Jul 15 '23 at 21:09
  • I wrote the answer on my own. No chat bot. Not sure what to say to convince you otherwise. Did any of my suggestions help the OP? – MatCat Jul 17 '23 at 06:11
  • I thought of a way to convince you that I'm not a bot. In my step 5 above, I pointed out that you need to use the .bin or .exe in the .dist folder after using the --standalone option. People who have used Nuitka will know that it can be really easy to accidentally select the .bin or .exe in the top level folder since that is where Nuitka saves the executable when run without --standalone. This is a common mistake, but not enough online discussion about this for a bot to come across it in a training set. – MatCat Jul 17 '23 at 15:41