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. :)
Related
I made an app that uses tkinter and tkinterdnd moudles. It works completely fine when I launch it as a script, however when I try to make and executable file from it and laucnh it, foloowing error ocures:
Traceback (most recent call last):
File "TkinterDnD2\TkinterDnD.py", line 53, in _require
_tkinter.TclError: can't find package tkdnd
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "IxcomGUI.py", line 128, in <module>
File "IxcomGUI.py", line 11, in __init__
File "TkinterDnD2\TkinterDnD.py", line 285, in __init__
File "TkinterDnD2\TkinterDnD.py", line 55, in _require
RuntimeError: Unable to load tkdnd library.
[14512] Failed to execute script 'IxcomGUI' due to unhandled exception!
I tried following:
Installed tkinterdnd2 with pip install and built with pyinstaller myscript.py.
Manually installed tkinterdnd2 module as shown in this video https://www.youtube.com/watch?v=JIy0QjwQBl0&t=605s&ab_channel=RamonWilliams and built with pyinstaller myscript.py
Repeated previous step, but added this thing https://github.com/pmgagne/tkinterdnd2/blob/master/hook-tkinterdnd2.py
Tried to implicitly tell pyinstaller path to tkdnd module with specifying path to the module with --paths flag.
All this attempts led to error bellow. Does anyone know some kind of solution?
The issue here is that Drag n Drop requires two components: the TCL libraries and the Tkinter interface to them. I install both manually to config my environment. (See my answer to How to Install and Use TkDnD with Python Tkinter on OSX?). I know someone packaged something on PyPI for the TkinterDnD2, but I haven't looked into it.
I have a project which uses TkinterDnD2. I build it with PyInstaller and see the same error you see (more or less). Running PyInstaller with the --onedir option (rather than the --onefile option), I saw that tkdnd2.8 was missing from my dist directory.
To rectify this, on Windows, I added
--add-binary "C:/Python/Python38-32/tcl/tkdnd2.8;tkdnd2.8"
to the PyInstaller command line, and that did the trick. I can now build a --onefile executable, and it runs without error.
Apparently it was unnexpectedly easy to fix this issue. All you need to is to get to the <YourPath>\Python39\tcl directory and find tkdnd2.8 directory, and move it to the tcl8.6 directory. I have also renamed it to just tkdnd, however I don't know whether it's necessary.
Here is the original link that saved my day: http://pyinstaller.47505.x6.nabble.com/tkinter-TclError-can-t-find-package-tkdnd-td2330.html
I'm using tkinterdnd2 installed from pip, and not TkinterDnD.
What really worked for me was this flag:
--add-data "C:/Users/myName/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0/LocalCache/local-packages/Python39/site-packages/tkinterdnd2;tkinterdnd2"
It expects tkdnd to be a folder inside tkinterdnd2. Just using additional-hooks/hidden import on tkinterdnd2 and tkdnd did now preserve that subfolder structure.
I am trying to use Gumbo's python wrapper to parse HTML.
My operating system is Ubuntu 14.04.3 LTS. I am using Python2.7
I have cloned the latest version of Gumbo from github.
I followed the installation steps provided on Github.
The installation of the libraries, both the C library and the python wrapper, appeared to be successful ( No error message, both printed successful messages at the end )
C library final message:
Libraries have been installed in: /usr/local/lib
Python wrapper message:
Installed
/usr/local/lib/python2.7/dist-packages/gumbo-0.10.1-py2.7.egg
Processing dependencies for gumbo==0.10.1 Finished processing
dependencies for gumbo==0.10.1
The first problem I encountered was when I tried to open pydoc for gumbo, to better understand the library.
pydoc gumbo produced the following error:
problem in gumbo - <type 'exceptions.OSError'>: /usr/local/lib/python2.7/dist-packages/gumbo-0.10.1-py2.7.egg/gumbo/libgumbo.so: cannot open shared object file: No such file or directory
Searching for the message yielded a single result.
It was not of much use to me.
Looking at the dist-packages directory, I noticed that libgumbo.so was not in /usr/local/lib/python2.7/dist-packages/gumbo-0.10.1-py2.7.egg/gumbo/ . All other files ( soup-adapter.py, gumboc.py, etc ) where there however.
The installation of the C library placed libgumbo.so ( and some other libraries, like libgumbo.a libgumbo.la, etc ) in /usr/local/lib. So, as a work around, I created a simlink from .../dist-packages/gumbo-0.10.1-py2.7.egg/gumbo/ to /usr/local/lib.
This got pydoc gumbo to work.
I tried to import gumbo and soup-adapter in the interpreter after. I received the following error:
import soup_adapter
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "soup_adapter.py", line 26, in <module>
import gumboc
File "gumboc.py", line 44, in <module>
os.path.dirname(__file__), _name_of_lib))
File "/usr/lib/python2.7/ctypes/__init__.py", line 443, in LoadLibrary
return self._dlltype(name)
File "/usr/lib/python2.7/ctypes/__init__.py", line 365, in __init__
self._handle = _dlopen(self._name, mode)
OSError: libgumbo.so: cannot open shared object file: No such file or directory
I am not sure how to proceed or how exactly to get gumbo to work.
I was attempting to install mitmproxy and run the "mitmproxy" and "mitmdump" from the Scripts folder.
However, I get tons of errors that a lot of modules are not found.
From the error messages I tried to install all the missing modules
Pry
PyOpenSSL
Pyasn
urwid
I stopped after that as I am not sure this will lead me to success.
a) is running and building mitmproxy on windows possible at all?
b) how can I get all the dependant modules and install them?
I reached the point where the package "urwid" is needed. However that fails with: "Unable to find vcvarsall.bat"
EDIT: it seems running mitmproxy is not really possible as the urwid package provides the terminal GUI which does not work for windows. However, I only need mitmdump. When I try running it I get:
C:\Python27\Scripts>C:\Python27\python.exe mitmdump -w out.txt
Traceback (most recent call last): File "mitmdump", line 41, in <module>
proxyconfig = proxy.process_proxy_options(parser, options)
File "C:\Python27\lib\site-packages\libmproxy\proxy.py", line 527, in process_
proxy_options certutils.dummy_ca(cacert)
File "C:\Python27\lib\site-packages\libmproxy\certutils.py", line 44, in dummy_castdin=subprocess.PIPE
File "C:\Python27\lib\subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\lib\subprocess.py", line 679, in __init__errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 893, in _execute_childstartupinfo)
WindowsError: [Error 2] System can not find file
C:\Python27\Scripts>
Maybe it can not find this certificate dummy file that is created. However, it didnt create the "mitmproxy-ca-cert.p12"
Help needed
mitmproxy's console interface (ncurses) doesn't run on Windows, although you can get it running under Cygwin. If you don't need an interactive user interface for your specific task, mitmdump (comes with mitmproxy) gets the job done as well. If you want to try out some alpha-quality software, you can also try mitmproxy's mitmweb and open the webinterface at http://localhost:8081/.
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.
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, ...