Cannot find module _frozen_importlib_external when running a frozen exe program - python-3.x

Hi I am pretty new to cx_Freeze, so when I try to freeze a Python file (it's just a basic hello world program) cx_Freeze creates an exe along with a bunch of other things. When I run the exe it gives me a "cannot find module _frozen_importlib_external" error. I am using Python 3.5 and running Windows 10. Any help is greatly appreciated. Thanks.

I had the same problem.
The issue here is that cx_freeze can't see the import and will not embed the package _frozen_importlib_external.
Change the file cx_Freeze/finder.py with the diff given at https://bitbucket.org/anthony_tuininga/cx_freeze/pull-requests/83/python-35-compatibility-for-cx_freeze-4x/diff and then build and install cx_Freeze again.

Related

Why does Tkinter work in the terminal but not in Pycharm?

Using Pycharm on Linux mint.
I installed the "future" package for the python interpreter which I'm using. Heres the script.
from tkinter import *
top = Tk()
top.mainloop()
Didn't work. It returns "ModuleNotFoundError: No module named 'tkinter'". Tkinter is infact installed. "python3 -m tkinter" confirms it. And when I compile the same code in the terminal, it displays.
As Bryan says, you're probably not using the Python version you think you're using. PyCharm tends to install its own version of Python. Once you have more than one version of Python installed, things get trickier.
To see what's happening, try running this script:
import sys
print(sys.executable, sys.version)
Or run those similar commands from the command line. That should help clarify matters.
The sys.executable will show you the full path to your Python executable. Great for seeing where the used Python installation is located.
I don't use Python on Linux, but perhaps one of your Python installations is version 2, in which case you would need to use:
from Tkinter import *
which is another way to confirm that the Python is version 2 rather than 3. If this is the case, you'll want to move to Python 3. I don't think anyone writes new projects in Python 2 anymore. It's defunct, purely legacy.
It's also possible that Python is installed on Linux without Tkinter. There are other posts on how to install Tkinter on Linux. For instance, you can check out ImportError: No module named 'Tkinter'
Thanks guys for the help I really appreciate it. But I found out the problem was because of Linux Mint's Software Manager. I initially downloaded pycharm using said software manager but it didnt work which is why I created the post. Then I deleted it, and downloaded pycharm through the tar.gz file from the jetbrains website. After doing that, it seems to work.

Issue making .exe with Pyinstaller : compilation is done but the .exe fails

I have a rather large python script that I would like to convert to .exe. I use PyInstaller and I managed to import every library needed so now I don't get any error message. My problem is that at some point, the .exe is stuck, so the conversion with PyInstaller didn't really worked. I suspect the issue is related to the PyAutoGui library, but I had to import it to convert my python script (I used pip install).
Does anyone else got the same issue? Is there something I can do to remove this issue?
I have python 3.9.2 and pyinstaller 4.2 and I am working with windows 10.
The libraries I had to import are : pyautogui, pandas, bs4, pygame, PyQt5, pywin32, winshell, pymysql, sqlalchemy, sqlalchemy.sql.default_comparator, wmi, Pillow, psutil and lxml.
Thanks for your suggestions!
In my experience, PyInstaller has had trouble generating .exe files from python scripts that use graphics libraries such as pygame and PyQt5. Mostly, it fails to generate the .exe and even when it does, the .exe takes a long time to load up and is really slow. If you want an .exe file, I would suggest trying out cx_freeze. To my knowledge, it won't generate .exe in one file like pyinstaller does, but the .exe file it does generate is of much higher quality.
We think we found the issue: pyautogui needs an other package called open-cv to work. Hope it'll help someone someday ;-)

import error with youtube_dl after compilation with pyinstaller

So I recently embedded youtube_dl into my python 3 project which all works very nicely.
The problem occurs when I compile that into an exe file using:
c:/python332/scripts/pyinstaller myprogram.py
It compiles fine, but upon running the exe I get an error similar to this:
Runtime Error!
Program: C:\python332\python.exe
R6034
An application has made an attempt to load the C runtime library incorrectly.
Please contact the application's support team for more information.
This specific error occurs if I go to the directory on command line, enter py -3 then try to import youtube_dl.
Interestingly, if I go to a different directory and then run py -3 and import youtube_dl it works perfectly fine (if the load time is a whee bit slow).
As extra information, for some reason pyinstaller is including both python27.dll and python37.dll, when I would have thought it would only want python37.dll?
Looking in the dist folder of the program I can see that a msvcr90.dll is present.
I am wondering is this some sort of compilation clash where pyinstaller is mixing python 2 and python 3 together?
Is there a known fix for this?
thanks.

FatalError failed to execute script. PyQt5

I know that questions have already been raised on this topic, but I believe that all decisions were strictly individual. The essence of the problem:
There is a calculator.py script and a kalkulator.py These files are in the same directory, the calculator file is executable, this is the file that I convert into an EXE using PyInstaller. Inside the file, I import several PyQt5 libraries, and the second file is Python: from kalkulator import *
The second file kalkulator.py contains the GUI of the program created with QtDesigner
When i run the command pyinstaller --onefile --debug calculator.py everything goes fine.
But when I run the EXE program file in debug mode, I see the following error:
The photo shows that the following error occurs.
"DLL Load Failed: The specified procedure could not be found."
I can assume that the problem is that when assembling, PyInstaller does not see the file kalkulator.py it contains a graphical interface.
What can you say about this problem, how do you think you can solve it?
I use:
Python 3.5
PyQt5
PyInstaller 3.3.1
I managed to solve my problem! I changed the version of Python 3.5.0 to 3.6.0, and also reinstalled PyQt5.

Error when Converting .py to .exe with cx_freeze

I am trying to convert my .py code to .exe. I tried all the options from posts on here and on the web, and all I could up with was the error below when I used cx_Freeze, and the .exe not opening when I used pyinstaller.
can someone help with the error below or give an alternative that works?
PS: my py code is actually ipython code from my jupyter notebook, but I'm trying not to share the code source.
Finally got it working while using pyinstaller, the key was to open the .exe file from the command window to be able to see the warning, which was "Import cv2 not found" after I deleted that line(since I was not using that module) and re built it, the .exe file now works. Hope this will help someone one day

Resources