Hello I've similar problem like this:
Py2Exe error caused by pywinauto on some systems: "AttributeError: 'module' object has no attribute 'CUIAutomation"
with py2exe and also pyinstaller I get error:
AttributeError: module 'comtypes.gen.UIAutomationClient' has no attribute 'CUIAutomation' [15964] Failed to execute script SVGWalker
Without py2exe or pyinstaller the script is running without errors !!
Here my startup python code:
#################################################################
# Version String
#################################################################
__version__ = "1.4.1.0"
#import WindowHandler
#import win32com.client
#import pywinauto
from pywinauto import application
from pywinauto import timings
from pywinauto import ElementNotFoundError
from pywinauto import Desktop
#import comtypes.client # 02.10.2020
import glob
import time
import sys
import os
import argparse
import traceback
import helper
import XmlManifest
and the error: with line 13 above:
Traceback (most recent call last):
File "SVGWalker.py", line 13, in <module>
from pywinauto import application
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "pywinauto\__init__.py", line 89, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "pywinauto\findwindows.py", line 42, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "pywinauto\controls\__init__.py", line 36, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "pywinauto\controls\uiawrapper.py", line 47, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "c:\python36\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "pywinauto\uia_defines.py", line 181, in <module>
File "pywinauto\uia_defines.py", line 169, in _build_pattern_ids_dic
File "pywinauto\uia_defines.py", line 50, in __call__
File "pywinauto\uia_defines.py", line 63, in __init__
AttributeError: module 'comtypes.gen.UIAutomationClient' has no attribute 'CUIAutomation'
[5732] Failed to execute script SVGWalker
Nothing in the thread above helped me.
Is there any other hint or solution
Related
When trying to run an exe I made using pyinstaller it fails while importing OpenGL with this traceback:
(env) C:\Users\me\myProject>.\dist\myProject\myProject.exe
Traceback (most recent call last):
File "main.py", line 6, in <module>
from igtools import IG
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "OpenGL\GL\__init__.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "OpenGL\error.py", line 12, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "PyInstaller\loader\pyimod03_importers.py", line 476, in exec_module
File "OpenGL\platform\__init__.py", line 36, in <module>
File "OpenGL\platform\__init__.py", line 30, in _load
TypeError: 'NoneType' object is not callable
[38272] Failed to execute script 'main' due to unhandled exception!
So I'm not sure exactly what the issue was. It seems like it had something to do with the pyinstaller hooks which I don't fully understand, but I did get it working with this specific combination of release versions:
pyinstaller==4.0
pyinstaller-hooks-contrib==2020.9
PyOpenGL==3.1.5
Maybe this will be helpful if anyone else runs into this.
I am working on a project which involves doing a language check for an input. When we try to turn it into a .exe file using PyInstaller, it gives away this errors:
C:\Users\luismanj\Allegations_TEF_ARG\dist>.\allegations.exe
Traceback (most recent call last):
File "allegations.py", line 16, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "C:\Users\luismanj\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "language_check.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "C:\Users\luismanj\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "langdetect\__init__.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "C:\Users\luismanj\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "langdetect\detector_factory.py", line 10, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "C:\Users\luismanj\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "langdetect\detector.py", line 9, in <module>
File "<frozen importlib._bootstrap>", line 991, in _find_and_load
File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
File "C:\Users\luismanj\Anaconda3\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 493, in exec_module
exec(bytecode, module.__dict__)
File "langdetect\utils\ngram.py", line 23, in <module>
File "langdetect\utils\ngram.py", line 24, in NGram
File "langdetect\utils\messages.py", line 22, in get_string
File "langdetect\utils\messages.py", line 9, in __init__
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\luismanj\\AppData\\Local\\Temp\\_MEI118322\\langdetect\\utils\\messages.properties'
[22436] Failed to execute script allegations
It seems the main problem as of now is the library Langdetect, which we have been using without issues until now. If anyone knows the cause or has found a workaround for this problem, any comment will be appreciated. Thank you.
When I do pyinstaller it executes successfully for python 3.7.
But when I execute the resulting exe I get the result under.
How can I correct this?
dist>mainlocal.exe
Traceback (most recent call last):
File "SpeechChangerLocal\mainlocal.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "d:\home\gitrep\ttt\local\venv\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "lib\site-packages\google\cloud\speech_v1\__init__.py", line 17, in <module>
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "d:\home\gitrep\ttt\local\venv\lib\site-packages\PyInstaller\loader\pyimod03_importers.py", line 623, in exec_module
exec(bytecode, module.__dict__)
File "lib\site-packages\google\cloud\speech_v1\gapic\speech_client.py", line 41, in <module>
File "lib\site-packages\pkg_resources\__init__.py", line 481, in get_distribution
File "lib\site-packages\pkg_resources\__init__.py", line 357, in get_provider
File "lib\site-packages\pkg_resources\__init__.py", line 900, in require
File "lib\site-packages\pkg_resources\__init__.py", line 786, in resolve
pkg_resources.DistributionNotFound: The 'google-cloud-speech' distribution was not found and is required by the application
[2900] Failed to execute script mainlocal
I imported google-cloud-speech_v1 instead of google-cloud-speech. Now it works.
I found "When Things Go Wrong" in manual very informative:
I am currently trying to put a Python app, which uses Sklearn modules, in a stand-alone .exe file.
My current cx_freeze setup.py looks like this:
import os
from cx_Freeze import setup, Executable
base = "Win32GUI"
os.environ['TCL_LIBRARY'] = r'C:\Users\...\AppData\Local\Continuum\anaconda3\tcl\tcl8.6'
os.environ['TK_LIBRARY'] = r'C:\Users\...\AppData\Local\Continuum\anaconda3\tcl\tk8.6'
executables = [Executable("gui_handler.py", base=base)]
packages = ["idna", "numpy", "sklearn", "nltk", "stop_words", "scipy", "scipy.sparse.csgraph._validation",
"scipy.spatial.ckdtree", "PyQt5", "imblearn.under_sampling", "imblearn.over_sampling",
"sklearn.tree._criterion"]
options = {
'build_exe': {
"packages": packages,
"excludes": ["scipy.spatial.cKDTree"],
"zip_include_packages": ["sklearn", "nltk", "idna"] # PyQt5 zippen verschlechtert die Optik
},
}
setup(
name="<any name>",
options=options,
version="1.0",
description='<any description>',
executables=executables
)
It worked fine before but the latest version of my application uses the module imblearn. I think it causes this problem (appears a few seconds after double-clicking the .exe file):
Traceback (most recent call last):
File "C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
module.run()
File "C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
exec(code, m.__dict__)
File "gui_handler.py", line 8, in <module>
File "C:\Users\...\Documents\PycharmProjects\MachineLearning\build\exe.win-amd64-3.6\TextClassification\init_predict.py", line 16, in <module>
from imblearn.under_sampling import RandomUnderSampler
File "C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\imblearn\under_sampling\__init__.py", line 6, in <module>
from .prototype_generation import ClusterCentroids
File "C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\imblearn\under_sampling\prototype_generation\__init__.py", line 6, in <module>
from .cluster_centroids import ClusterCentroids
File "C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\imblearn\under_sampling\prototype_generation\cluster_centroids.py", line 14, in <module>
from sklearn.cluster import KMeans
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\cluster\__init__.py", line 6, in <module>
from .spectral import spectral_clustering, SpectralClustering
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\cluster\spectral.py", line 17, in <module>
from ..manifold import spectral_embedding
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\manifold\__init__.py", line 9, in <module>
from .t_sne import TSNE
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\manifold\t_sne.py", line 25, in <module>
from . import _barnes_hut_tsne
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "ExtensionLoader_sklearn_manifold__barnes_hut_tsne.py", line 23, in <module>
File "ExtensionLoader_sklearn_manifold__barnes_hut_tsne.py", line 15, in __bootstrap__
File "C:\Users\...\AppData\Local\Continuum\anaconda3\lib\imp.py", line 343, in load_dynamic
return _load(spec)
File "sklearn\neighbors\quad_tree.pxd", line 54, in init sklearn.manifold._barnes_hut_tsne
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "ExtensionLoader_sklearn_neighbors_quad_tree.py", line 23, in <module>
File "ExtensionLoader_sklearn_neighbors_quad_tree.py", line 15, in __bootstrap__
File "C:\Users\...\AppData\Local\Continuum\anaconda3\lib\imp.py", line 343, in load_dynamic
return _load(spec)
File "sklearn\tree\_criterion.pxd", line 21, in init sklearn.neighbors.quad_tree
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\tree\__init__.py", line 6, in <module>
from .tree import DecisionTreeClassifier
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "C:\Users\...\AppData\Local\Continuum\anaconda3\lib\site-packages\sklearn\tree\tree.py", line 40, in <module>
from ._criterion import Criterion
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "ExtensionLoader_sklearn_tree__criterion.py", line 23, in <module>
File "ExtensionLoader_sklearn_tree__criterion.py", line 15, in __bootstrap__
File "C:\Users\...\AppData\Local\Continuum\anaconda3\lib\imp.py", line 343, in load_dynamic
return _load(spec)
File "sklearn\tree\_splitter.pxd", line 34, in init sklearn.tree._criterion
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "ExtensionLoader_sklearn_tree__splitter.py", line 23, in <module>
File "ExtensionLoader_sklearn_tree__splitter.py", line 15, in __bootstrap__
File "C:\Users\...\AppData\Local\Continuum\anaconda3\lib\imp.py", line 343, in load_dynamic
return _load(spec)
File "sklearn\tree\_criterion.pxd", line 21, in init sklearn.tree._splitter
AttributeError: module 'sklearn.tree._criterion' has no attribute 'Criterion'
I took a look in the sklearn\tree\tree.py file and there is indeed this import statement:
from ._criterion import Criterion
The same folder contains the files:
_criterion.cp36-win_amd64.pyd
_splitter.cp36-win_amd64.pyd
_tree.cp36-win_amd64.pyd
_utils.cp36-win_amd64.pyd
which are python module files as far as I know.
The application runs perfectly fine if I execute it from the PyCharm IDE so I would either assume that my program doesn't even need the Criterion module (and cx_freeze just loads it because it loads everything) and therefore I don't get the error message at runtime. Or that the module is actually missing.
Any ideas what could fix this problem?
Okay, I fixed the problem myself.
I just removed the line
zip_include_packages": ["sklearn", "nltk", "idna"]
from my cx_freeze_setup.py.
pip command is showing error.
i downloaded libraries from https://github.com/rajpaul/igotoeurope/blob/master/requirements.txt then it started showing error in pip. i tried uninstalling the pip command and reinstalling the same still it didn't work.
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/pip/_vendor/init.py", line 33, in vendored
import(vendored_name, globals(), locals(), level=0)
ModuleNotFoundError: No module named 'pip._vendor.cachecontrol'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/bin/pip3", line 9, in <module>
from pip import main
File "/usr/lib/python3/dist-packages/pip/__init__.py", line 22, in <module>
from pip._vendor.requests.packages.urllib3.exceptions import DependencyWarning
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 64, in <module>
vendored("cachecontrol")
File "/usr/lib/python3/dist-packages/pip/_vendor/__init__.py", line 36, in vendored
__import__(modulename, globals(), locals(), level=0)
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/__init__.py", line 9, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/wrapper.py", line 1, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "/usr/share/python-wheels/CacheControl-0.11.7-py2.py3-none-any.whl/cachecontrol/adapter.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "/usr/share/python-wheels/requests-2.18.4-py2.py3-none-any.whl/requests/__init__.py", line 84, in <module>
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 656, in _load_unlocked
File "<frozen importlib._bootstrap>", line 626, in _load_backward_compatible
File "/usr/share/python-wheels/urllib3-1.22-py2.py3-none-any.whl/urllib3/contrib/pyopenssl.py", line 46, in <module>
File "/home/aaroosh/.local/lib/python3.6/site-packages/OpenSSL/__init__.py", line 8, in <module>
from OpenSSL import rand, crypto, SSL
File "/home/aaroosh/.local/lib/python3.6/site-packages/OpenSSL/rand.py", line 11, in <module>
from OpenSSL._util import (
File "/home/aaroosh/.local/lib/python3.6/site-packages/OpenSSL/_util.py", line 3, in <module>
from cryptography.hazmat.bindings.openssl.binding import Binding
File "/home/aaroosh/.local/lib/python3.6/site-packages/cryptography/hazmat/bindings/openssl/binding.py", line 13, in <module>
from cryptography.hazmat.bindings._openssl import ffi, lib
AttributeError: module '_cffi_backend' has no attribute '_init_cffi_1_0_external_module'
I solved it by removing OPENSSL library.