I am creating a medium level application in Python.
Everything works well now, and I am trying to make this a windows executable with py2exe.
The executable is created fine, but when I try to run it, it fails with the following error.
File "zipextimporter.pyo", line 82, in load_module
File "ffhandler.pyo", line 33, in ?
File "zipextimporter.pyo", line 82, in load_module
File "pyAA\__init__.pyo", line 1, in ?
File "zipextimporter.pyo", line 82, in load_module
File "pyAA\AA.pyo", line 8, in ?
File "zipextimporter.pyo", line 82, in load_module
File "pyAA\pyAAc.pyo", line 5, in ?
File "zipextimporter.pyo", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading pyAA\_pyAAc.pyd
I am using pyAA in this application. I searched internet, but was unable to get any solution.
I copied msvcp71.dll to windows/system32, but still issue is there.
I had solved it earlier (around 7 months back), but my hard drive crashed and when I try to recreate it, I cannot seem to solve it now. :-(
I would be much obliged if someone could help me out here.
EDIT:
When I use py2exe without bundle files option, it is working perfectly. But when I use bundle file option, it is failing.
I tried without zipfile option, wherein it creates a library.zip alongwith the executable. Again it failed. I did unzip of library.zip using 7-zip, and found that _pyAAc.pyd is there in pyAA folder inside the zip file. So, it looks like some issue with memoryloadlibrary function.
When I tried to unzip using windows unzip function, it failed. I had to use 7-zip to unzip it. Is it a possible clue?
You're missing some DLL's in your build...
First search your hard drive for the file _pyAAC.pyd. Make sure it is included (shipped) in your build.
Then use 'dependency walker' on the .pyd file (in your py2exe compiled version!) to see what it is that is still missing (other DLL's which are causing the MemoryLoadLibrary message for the .pyd file). Make sure these dependencies are also shipped, ...
Related
my issue is that i've been trying to make an exe file with a .py that I created, but it doesn't work. I executed the converted .exe file from the console to see the log and I got this:
Traceback (most recent call last):
File "professors.py", line 10, in <module>
File "PyInstaller\loader\pyimod03_importers.py", line 531, in exec_module
File "docx2pdf\__init__.py", line 13, in <module>
File "importlib\metadata.py", line 551, in version
File "importlib\metadata.py", line 524, in distribution
File "importlib\metadata.py", line 187, in from_name
importlib.metadata.PackageNotFoundError: docx2pdf
[6940] Failed to execute script professors
I've been reading about the issue and it seems that pyinstaller doesn't recognize the docx2pdf import. I read in a website that I have to add it in a folder called site-packages, but it is supposed to have another folder inside called pyInstaller, which is not there. I also tried adding the folder manually but it still didn't work. I also tried with the --hidden-imports method but im not sure how to exactly use it.
I will have to apply this to other imports that I have also.
Any ideas? Thanks in advance!
I had a identical issue. I removed lines 7-13 from the docx2pdf module:
try:
# 3.8+
from importlib.metadata import version
except ImportError:
from importlib_metadata import version
__version__ = version(__package__)
and line 119...
print(__version__)
After that, it worked. Modifying the module probably isn't the best solution, and of course I'd recommend backing up the module before modifying it, but I hope it works for you too.
I'm currently trying to package a Tkinter app into a .exe file using py2exe. The packaging works fine, and up until a point, the program functions. When I call a certain function, though, running the .exe file logs the following error:
Exception in Tkinter callback
Traceback (most recent call last):
File "Tkinter.pyc", line 1532, in __call__
File "/Users/Gordon/Gordon's Files/AutoFormatter/lib\formatterApp.py", line 58, in go
File "formatter.pyc", line 72, in take
File "docx\api.pyc", line 25, in Document
File "docx\opc\package.pyc", line 116, in open
File "docx\opc\pkgreader.pyc", line 32, in from_file
File "docx\opc\phys_pkg.pyc", line 31, in __new__
PackageNotFoundError: Package not found at 'C:\Users\Gordon\Gordon's Files\AutoFormatter\dist\library.zip\docx\templates\default.docx'
Upon originally running py2exe, I checked the \docx\ folder and found that py2exe hadn't actually copied over the \templates\ folder. After manually unzipping the library.zip, adding in the \templates\ folder in the right place, and then manually re-zipping, however, I get the same error.
My setup.py is as follows:
from distutils.core import setup
import py2exe
setup(
windows=[{'script': 'AutoFormatter.py'}],
options={
'py2exe':
{
'includes': ['lxml.etree', 'lxml._elementpath', 'gzip', 'docx'],
}
}
)
I'm running the program on a Windows 7 computer using Python 2.7.8 and py2exe 0.6.9.
This might be too late but I have been having the same troubles as well. I don't know if python-docx was made to be compiled into a single executable yet, none the less I have found solution.
I am on pyinstaller with python2.7, essentially the same thing. I hope that you are freezing into one directory rather than one file. This won't work if you're freezing to one file
Download this here(Mediafire link)
Place it in
C:\Users\Gordon\Gordon's Files\AutoFormatter\dist\library.zip\docx\templates\default.docx
basically wherever your .exe is in.
Hopefully that does the trick
Based off of me scouring through my own directories and the docx module, when you create a document:
doc = Document()
doc.save('hello.docx')
It pulls a template for you to use, if you do not create your own, it will use the default template offered by python-docx itself.
Don't quote me on this, but I believe python-docx looks through its own directories to find the default.docx template when executing it through python.
Since we compiled the script, the path changed to the directory in which the .exe is placed, however pyinstaller (or in your case py2exe) does not include the template with the dist folder, and this creates the PackageNotFoundError
I have a python application primarily dependent on matplotlib, tkinter, numpy and scipy I have been distributing for multiple operating systems. I build these on top of the python.org version of python 2.6. For mac, I have had good success in the past with py2app and pyinstaller to build standalone versions of my application. Recently, however, I have included functions that require patsy, pandas and igraph and have had to move to the mac distributed version of python 2.6 in order to get igraph to work. All works fine in building a py2app version of my software on the Mac for my OS (10.6) but when I run on 10.8 I encountered the following error:
Traceback (most recent call last):
File "UI.pyc", line 603 createHeatMap
File "clustering.pyc", line 31, in <module>
File "mpl_toolkits/__init__.pyc", line 2, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 698, in <module>
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 701, in Environment
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 96, in get_supported_platform
File "/System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/pkg_resources.py", line 222, in get_build_platform
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/util.py", line 98, in get_platform
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/sysconfig.py", line 537, in get_config_vars
File "/System/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/distutils/sysconfig.py", line 405, in _init_posix
DistutilsPlatformError: invalid Python installation: unable to open /user/include/python2.6/pyconfig.h (No such file or directory)
This is fixed by saving the file pyconfig.h to the designated location on the destination machine (not present in 10.8 but present in 10.6), which allows my application to work fine. In my py2app pacakge directory, under "Contents/Resources" there is a sym-link to the directory "include" which points to: /System/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6/pyconfig.h. If I include the pyconfig.h file as an addition resource in my py2app setup file, it also includes it in the package, but it still is not recognized.
Can anyone suggest a good work around for this that doesn't require me to use the python.org version of python (I've had horrible luck getting igraph to work with this).
Thanks...
This is a known issue in py2app, see https://bitbucket.org/ronaldoussoren/py2app/issue/36/py2app-fails-to-build-a-working-executable. The pyconfig.h file is only present on machines where the developer tools are installed, which is why I haven't noticed the problem myself.
The easiest workaround is probably to replace the pyconfig.h symlink by a copy of the file after creating the app bundle.
I've never used py2exe before. I installed the package, created a setup.py, ran it and it seemed to work without any obvious errors. I went into the dist folder it created and tried to run the exe but I'm getting this error:
Traceback (most recent call last):
File "rl2.py", line 3, in <module>
File "libtcodpy.pyc", line 41, in <module>
File "ctypes\__init__.pyc", line 428, in __getitem__
File "ctypes\__init__.pyc", line 423, in __getattr__
File "ctypes\__init__.pyc", line 353, in __init__
WindowsError: [Error 126] The specified module could not be found
How can I solve this?
What exact commands did you use to get this output?
I recommend using PyInstaller.
You can build an EXE with PyInstaller using this command:
"python pyinstaller.py -y -w -F [PATH\TO\SCRIPT.py] -n [PROJECT_NAME]"
-y: answer yes to every question
-w: windowed (does not show commandline when running)
-F: Compile into one EXE instead of a directory with .dll files
-n: assign project name
Hope I helped
You probably need to manually specify ctypes in the packages section of your setup.py.
See here
I had same issue today. HEre is the solution will work 100%
The meaning of error is the imported dll file in your code is misssng in created dist folder. so you have to copy and paste dll file in dist folder, and it will work.
I used logimove.dll file and same issue. so i put logimove.dll file in dist file and it works. :)
I have created a simple program which uses pywin32. I want to deploy it as an executable, so I py2exe'd it. I also didn't want a huge amount of files, so I set bundle_files to 1 (meaning bundle everything together). However, when I attempt running it, I get:
Traceback (most recent call last):
File "pshelper.py", line 4, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "win32.pyc", line 8, in <module>
File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading win32ui.pyd
In my setup script, I tried doing packages=["win32ui"] and includes=["win32ui"] as options, but that didn't help. How can I get py2exe to include win32ui.pyd?
I don't have this problem if I don't ask it to bundle the files, so I can do that, for now, but I'd like to know how to get it to work properly.
Are you sure that the problem is that win32ui.pyd is not included? The stack trace isn't exactly the same as noted in the wiki, but check this out: http://www.py2exe.org/index.cgi/Py2exeAndWin32ui.
The work-around that has worked best so far is to simply re-implement the pywin32 functions using ctypes. That doesn't require another .pyd or .dll file so the issue is obviated.
Do care to try out PyInstaller? I've used it both on Windows 7 and Ubuntu 10.04 and it worked like magic, even when I compiled to .pyd on Windows.
I've been able to bundle all sorts of applications that I've developed with it.
I have the same problem trying to bundle psutil with py2exe. Here is what I found so far.
Traceback (most recent call last):
File "wx_gui.py", line 43, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "psutil\__init__.pyc", line 85, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "psutil\_psmswindows.pyc", line 15, in <module>
File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading _psutil_mswindows.pyd
I get this traceback when bundle_files = 3. zipfile may be specified or may be None, I still get the problem.
First, I thought this was a missing dll because of this page:
http://www.py2exe.org/index.cgi/ProblemsToBeFixed
I've copied all the dlls I found in Python27 into the same directory as the executable and added that directory path to os.environ['path']. That didn't worked.
Then I tried to import my package directly from site-packages.
I've replaced the whole sys.path of my compiled executable with my normal sys.path
sys.path = [r'C:\Python27\Lib\idlelib', ...]
I think the .pyd module got imported but Visual c++ threw me this really ugly error message:
Runtime Error!
Program: {path}.exe
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
I suggest you try to replace the whole sys.path to see if it is working. If it is, you could always make your single executable write the necessary module into a temp directory and add it to your path. If not, I feel like this problem is going to be hard to solve.