ModuleNotFoundError when converting from .py to .exe

464 Views Asked by At

I created a program in Pycharm which uses the following library:

import sys
sys.coinit_flags = 2
import tkinter as tk
from tkinter import filedialog, ttk, messagebox
import os
import zipfile
import shutil
from pynput.keyboard import Key, Controller
from pywinauto import application
import time

When I run it in Pycharm, everything works fine. I want to be able to share the script with my colleagues who will not have Python on their desktop, so I wanted to change the .py file to an .exe. For this I used auto-py-to-exe. However after the .exe file was made, it wouldn't run and gave me this error:

Traceback (most recent call last):
  File "unzipper.py", line 18, in <module>
ModuleNotFoundError: No module named 'pynput'
[2076] Failed to execute script unzipper

I read through the documentations on the auto-py-to-exe errors. And as I tried the fix for the ModuleNotFoundError, I'm still getting the same error.

Hidden import

Wondering if anyone knows how to fix this. Just as additional info, I'm using Python 3.8

edit:

I've also tried to install it manually using pyinstaller. But still no luck. The .py file would run perfectly, but the .exe would give this error:

error

0

There are 0 best solutions below