The issue
I developed a PyQt app that uses NLTK to throw item recommendations based on a query, and now I need to package it into a standalone app. After checking the internet for weeks, I tried fbs, but ended up going to pyinstaller. When I tweaked the necessary things, the app was succesfully built... For Linux. Issue here is, I need it to be able to run on Windows, and I'm using Ubuntu.
In order to package it for Windows, I read everywhere that the best choice is to just wine pyinstaller and call it a day, but when I do that, I end up with this error message:
OSError [WinError 127] Procedure not found: 'RtlIpv6AddressToStringA'
For what I can collect, this is a semi-usual thing, since it looks like NLTK and PyInstaller do not get along well.
What I tried
Modifying hook-nltk.py and changed the lines regarding nltk_data
Using PyInstaller with the .py file as well as the .spec file
Looking pretty much everywhere finding someone with a similar problem, to no avail
I am building a GUI tkinter python3 application and attempting to compile it with py2app. For some reason when I try to launch the .app bundle in the dist folder it gives me this error:
A main script could not be located in the Resources folder
I was wondering why it is doing this, as it is rather frustrating, and I can not find anything about it anywhere. I copied my .py file into the resources folder (Networking.py). Previous to this error I also found an error in the Info.plist. In the key where it states the runtime executable, I found it was trying to get python2.7, which I have updated and am no longer using. I changed it to my current version, which the path for looks like this:
/Library/Frameworks/Python.framework/Versions/3.6/Python
It may be worth noting that it had a strange path previously, which did not look like a proper path to me. It was #executable_path/../Frameworks/Python.framework/Versions/2.7/PythonI removed this completely... Was this wrong? I have no idea about anything about XML, which is what it seemed to be...
Also when compiling this happened:
error: [Errno 1] Operation not permitted: '/Users/Ember/dist/Networking.app/Contents/MacOS/Networking'
Any help would be highly appreciated! Thanks!
EDIT
I actually figured out: a bit of a stupid mistake, but since I'm using python 3.x I have to type in python3 before doing it.
In your "setup.py" file that you used to create the application, did you remember to list all the modules used in your code. For example, if you used the OS and Glob modules, then you would add this to your setup.py next to "OPTIONS":
OPTIONS = {'argv_emulation': True, 'includes':['glob', 'os']}
Basically, anything that you import into your module, you should include in the setup.py. Let me know if that works.
I actually figured out: a bit of a stupid mistake, but since I'm using python 3.x I have to type in python3 before doing it.
I had the same problem.
python setup.py py2app
I tried
python3 setup.py py2app
and it worked just fine. Hope this helps.
I have created a desktop gui application which i want to package. I was directed to use pyinstaller to package it so i did. I have a mainwindow.py file where i import a resource file (converted to python code) as well as other imports going on in there. However when i run the output file,it gives me an error. I suspected it was due to my resource file, from the error so i tried pyinstaller on one of the modules and it worked perfectly. however i keep getting an error with the MainWindow.py file. I have the image of the error here for your consideration. How do i go around this error?
I have managed to solve the problem. After reading this answer, I tried pyrcc4 with the '-py3' flag and it worked. I think without the py3 flag,the resource file is converted into a python 2.x code. And I was trying to interpret py2 code with py3 interpreter. That's my understanding of the problem tho. But in case you have a similar problem,try using the -'py3' flag for python3 interpreter.Good Luck
I'm running Python 3.1 on Windows and I'm trying to distribute my Pygame script as an executable via cx_Freeze. Right now it seems to be working except that the exe build can't load any of my images:
Cannot load image: C:\path\to\build\exe.win32-3.1\resources\image.png
File is not a Windows BMP file
Googling has revealed that this happens when the SDL imaging library doesn't get included correctly. However, SDL_image.dll and libpng12-0.dll are both put by cx_Freeze into my build directory, so it seems to me like everything should be fine. Why wouldn't it be able to load PNG images?
EDIT: I "solved" this problem by porting my script to Python 2.6 and using py2exe instead since it had some functionality anyway that I needed.
I encountered the same issue many times, but I found out how to deal with it.
The problem
It seems that there is a conflict between two possible dependencies. The file jpeg.dll is included from the JRE (on Windows, something like C:\Program Files\Java\jre6\bin\), but it is the wrong one. It should be included from the Pygame directory, located within your Python installation, at C:\Python31\lib\site-packages\pygame\. Don't know why cx_Freeze prefers the one from the JRE, though…
How to fix it?
It is quite easy. Just copy the correct file (the one from Pygame) to the directory in which you execute the cx_Freeze script. When you will start it, the script will look in the current directory first, and will find the correct jpeg.dll. Your executable should be able to import PNG images now.
Test by inserting some python code to display one message indicating that the libraries have loaded and another message to indicate that their loading resulted in an error.
try:
import SDL_image
print "Loaded SDL_image"
except:
print "Failed to import SDL_image"
try:
import libpng
print "Loaded libpng"
except:
print "Failed to import libpng"
I am using python 2.6 on XP. I have just installed py2exe, and I can successfully create a simple hello.exe from a hello.py. However, when I try using py2exe on my real program, py2exe produces a few information messages but fails to generate anything in the dist folder.
My setup.py looks like this:
from distutils.core import setup
import py2exe
setup(console=['ServerManager.py'])
and the py2exe output looks like this:
python setup.py py2exe
running py2exe
creating C:\DevSource\Scripts\ServerManager\build
creating C:\DevSource\Scripts\ServerManager\build\bdist.win32
...
...
creating C:\DevSource\Scripts\ServerManager\dist
*** searching for required modules ***
*** parsing results ***
creating python loader for extension 'wx._misc_' (C:\Python26\lib\site-packages\wx-2.8-msw-unicode\wx\_misc_.pyd -> wx._misc_.pyd)
creating python loader for extension 'lxml.etree' (C:\Python26\lib\site-packages\lxml\etree.pyd -> lxml.etree.pyd)
...
...
creating python loader for extension 'bz2' (C:\Python26\DLLs\bz2.pyd -> bz2.pyd)
*** finding dlls needed ***
py2exe seems to have found all my imports (though I was a bit surprised to see win32 mentioned, as I am not explicitly importing it). Also, my program starts up quite happily with this command:
python ServerManager.py
Clearly I am doing something fundamentally wrong, but in the absence of any error messages from py2exe I have no idea what.
I put this in all my setup.py scripts:
distutils.core.setup(
options = {
"py2exe": {
"dll_excludes": ["MSVCP90.dll"]
}
},
...
)
This keeps py2exe quiet, but you still need to make sure that dll is on the user's machine.
I've discovered that py2exe works just fine if I comment out the part of my program that uses wxPython. Also, when I use py2exe on the 'simple' sample that comes with its download (i.e. in Python26\Lib\site-packages\py2exe\samples\simple), I get this error message:
*** finding dlls needed ***
error: MSVCP90.dll: No such file or directory
So something about wxPython makes py2exe think I need a Visual Studio 2008 DLL. I don't have VS2008, and yet my program works perfectly well as a directory of Python modules. I found a copy of MSVCP90.DLL on the web, installed it in Python26/DLLs, and py2exe now works fine.
I still don't understand where this dependency has come from, since I can run my code perfectly okay without py2exe. It's also annoying that py2exe didn't give me an error message like it did with the test_wx.py sample.
Further update: When I tried to run the output from py2exe on another PC, I discovered that it needed to have MSVCR90.DLL installed; so if your target PC hasn't got Visual C++ 2008 already installed, I recommend you download and install the Microsoft Visual C++ 2008 Redistributable Package.
wxPython has nothing to do with it. Before Python 2.6, Python used Visual Studio 2003 as their Windows compiler. Beginning with 2.6, they switched to Visual Studio 2008, which requires a manifest file in some situations. This has been well documented. See the following links:
http://wiki.wxpython.org/py2exe
http://py2exe.org/index.cgi/Tutorial#Step52
Also, if you're creating a wxPython application with py2exe, then you want to set the windows parameter, NOT the console one. Maybe my tutorial will help you:
http://www.blog.pythonlibrary.org/2010/07/31/a-py2exe-tutorial-build-a-binary-series/
It looks like this is only a dependency for Python 2.6. I wasn't getting this error under 2.5, but after the upgrade I am.
This email thread has some background for why the problem exists and how to fix it:
http://www.nabble.com/py2exe,-Py26,-wxPython-and-dll-td20556399.html
I didn't want to have to install the vcredist. My application currently requires no installation and can be run by non-administrators, which is behavior I don't want to lose. So I followed the suggestions in the links and got the necessary Microsoft.VC90.CRT.manifest and msvcr90.dll by installing Python "for this user only". I also needed msvcp90.dll that I found in the WinSxS folder of an "all users" Python 2.6 install. Since I already had two of the three, I included msvcm90.dll to prevent future errors though I didn't get any immediate errors when I left it out. I put the manifest and the three DLLs in the libs folder used by my frozen application.
The trick I had to perform was including an additional copy of the manifest and msvcr90.dll in the root of my application folder next to by py2exe generated executable. This copy of the DLL is used to bootstrap the application, but then it appears to only look in the libs folder.
Hopefully that discovery helps someone else out.
Also, I had the same problem with having py2exe log a real error message. Then I realized that stderr wasn't getting redirected into my log file. Add "> build.log 2>&1" on the command line where you invoke py2exe.
import sys
sys.path.append('C:\\WINDOWS\\WinSxS\\x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_5090ab56bcba71c2')
On each Windows, you can find the file MSVCP90.dll in some subdirectory in C:\\WINDOWS\\WinSxS\\
In my case, the directory was: x86_microsoft.vc90.crt_1fc8b3b9a1e18e3b_9.0.30729.4148_none_5090ab56bcba71c2.
Go to C:\\WINDOWS\\WinSxS\\ and use windows file search to find MSVCP90.dll.
Just for your info, for me it worked to copy the files
Microsoft.VC90.CRT.manifest
msvcr90.dll
into the directory with the .exe on the user's machine (who has no python or VC redistributable installed).
Thanks for all the hints here!
The output says you're using WX. Try running py2exe with your script specified as a GUI app instead of console. If I'm not mistaken, that tends to cause problems with py2exe.
Try this: http://www.py2exe.org/index.cgi/Tutorial#Step52
It worked for me
There is some info on the wxPython wiki.
Deploy a Python app
py2exe with wxPython and Python 2.6
On my win8.1, I do not find the path
c:/Program Files/Microsoft Visual Studio 9.0/VC/redist/x86/Microsoft.VC90.CRT
On the contrary , the dll is found in
C:/WINDOWS/WinSxS/x86_Microsoft.VC90.CRT_XXXXXXX
The XXX may vary according to your PC
You may search in the path , then add the path in you setup.py
import sys
sys.path.append('C:/WINDOWS/WinSxS/x86_Microsoft.VC90.CRT_XXXXXXX')
import sys
sys.path.append('c:/Program Files/Microsoft Visual Studio 9.0/VC/redist/x86/Microsoft.VC90.CRT')