omar18881
omar18881

Reputation: 49

PyInstaller cannot check for assembly dependencies

I am trying to make Tkinter GUI module with a build option to build Exes after the user puts some inputs & I don't want him to install python and pyinstaller to be able to Compile the code to Exe.

Using Python 3.6.0

I made 2 python scripts first-named compiler.py & other hello.py hello.pyprint("Hello World")

compiler.py

import PyInstaller.__main__
import ctypes
import win32ctypes
from win32ctypes import pywin32
from win32ctypes.pywin32 import pywintypes
import os

def compiling():
    PyInstaller.__main__.run([
        # '--name=%s' % package_name,
        '--onefile',
        '--windowed',
        # '--add-binary=%s' % os.path.join('resource', 'path', '*.png'),
        # '--add-data=%s' % os.path.join('resource', 'path', '*.txt'),
        # '--icon=%s' % os.path.join('resource', 'path', 'icon.ico'),
        os.path.join('hello.py'),  # my_package is a Directory
        # '--version-file=%s' % os.path.join('assembly.txt'),
    ])
compiling()

when I try to Compile compiler.py with pyinstaller it compiles successfully with -->pyinstaller --onefile --console compiler.py

but when I try to run the exe it throws

PyInstaller cannot check for assembly dependencies.
Please install pywin32-ctypes.

pip install pywin32-ctypes

What I Have Tried? 1-i installed pywin32-ctypes successfully 2-Tried to compile compiler.py with different alternatives other than pyinstaller 3-cx-freeze & nuitka both of them throw the same error when I Run after compiling. 4- tried using Python 3.7.5 on other machine start new fresh Throw the Same Error the reason I choose pyinstaller because it can build 1 EXE

https://github.com/pyinstaller/pyinstaller/issues/3892

https://github.com/pyinstaller/pyinstaller/issues/3793

Unable to run PyInstaller - "Please install PyWin32 or pywin32-ctypes"

All those Failed As Well is it something I am Doing Wrong or is Pyinstaller Problem

Upvotes: 4

Views: 9299

Answers (9)

Deepansh Bhatia
Deepansh Bhatia

Reputation: 13

I ran into the same issue. I had modified the .spec file generated by PyInstaller and provided the wrong virtual environment path in the Analysis. The virtual environment didn't exist, so PyInstaller could not check for assembly dependencies.

Upvotes: 0

Thisal
Thisal

Reputation: 310

i got this broblem too. i fixed it...

first -> uninstall pywin32-ctypes -> pip uninstall pywin32-ctypes second -> install again -> pip install pywin32-ctypes

maybe this working ..!

Upvotes: 0

Shaurya Chhabra
Shaurya Chhabra

Reputation: 72

I had the same issue and had to upgrade pyinstaller using

pip install --upgrade pyinstaller

It must be some kind of problem with the packages pyinstaller uses, It might have updated the packages while upgrading pyinstaller too.

Upvotes: 0

Ben Etherington
Ben Etherington

Reputation: 35

Alternatively, it looks like PyInstaller doesn't like running in a virtual environment. deactivateing the venv, then pip install pyinstaller and pyinstaller pyinstaller.spec worked for me.

Upvotes: 1

nimig18
nimig18

Reputation: 876

Ok I think I have figure it out the pip3 install pyinstaller was installing it in the ~\AppData\Roaming\Python\Python37\Scripts directory. I had to to uninstall it via pip3 uninstall pyinstaller. Then navigate to the python3 root install directory then run python.exe -m pip install pyinstaller.

Not sure what this means, but I'm no longer getting the following error:

PyInstaller cannot check for assembly dependencies.
Please install pywin32-ctypes.

pip install pywin32-ctypes

Upvotes: 0

I had similar issue.The above methods didnt work.I used env method ,(env) C:\Users\RAMAJAYAM>python -m PyInstaller --name "tkinterapp1.py" "C:\Users\RAMAJAYAM\tkinterapp1.py" and compiled successfully.Exe works fine.

Upvotes: 0

Evair Silvester
Evair Silvester

Reputation: 23

I solved this on Windows on command prompt, first navigate using cd, till reach the folder Scripts:

C:\Users\john\Envs\yourEnv\Scripts

You'll see a pyinstaller.exe

Then call it on cmd:

    pyinstaller --onefile --clean --name myApp "C:\path\to\your\script\example.py"

The resulting folders will be Dist and Build and they will be on first path you see here "C:\Users\john\Envs\yourEnv\Scripts". The file .exe is on Dist.

Upvotes: 0

ErdoganOnal
ErdoganOnal

Reputation: 880

An old question but maybe someone could face the same issue. I found a solution and it works for me.

Installing this module solves the problem

pip install cffi

After installing, I tried the build again. Gives error-like warning.

Traceback (most recent call last):
  File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'win32com'
Traceback (most recent call last):
  File "<string>", line 2, in <module>
ModuleNotFoundError: No module named 'win32com'

You can fix this warning via installing pywin32

pip install pywin32

I hope it helped someone else.

Upvotes: 9

NerdWizard73
NerdWizard73

Reputation: 99

I had the exact same issue.

The fix for me was making an edit to a couple of lines in the Pyinstaller compat.py file.

Navigate to your python directory -> Lib -> site-packages -> Pyinstaller.

Open compat.py and look for the following:

if is_win:
    try:
        from win32ctypes.pywin32 import pywintypes  # noqa: F401
        from win32ctypes.pywin32 import win32api
    except ImportError:
        # This environment variable is set by seutp.py
        # - It's not an error for pywin32 to not be installed at that point
        if not os.environ.get('PYINSTALLER_NO_PYWIN32_FAILURE'):
            raise SystemExit('PyInstaller cannot check for assembly dependencies.\n'
                         'Please install pywin32-ctypes.\n\n'
                         'pip install pywin32-ctypes\n')

Change both of those import statements to import the modules themselves instead of trying to grab them from win32ctypes.pywin32.

    #from win32ctypes.pywin32 import pywintypes  # noqa: F401
    #from win32ctypes.pywin32 import win32api
    import pywintypes
    import win32api

I hope that helps!

Upvotes: 8

Related Questions