Trying to compile a Python 2.7 script with py2exe, I found this error:
Traceback (most recent call last):
File "OH_T_1.py", line 28, in <module>
File "GUI_main_1.pyc", line 6, in <module>
File "OH_T_1.pyc", line 29, in <module>
File "export_BD_spatialite_OH_T.pyc", line 13, in <module>
File "pyspatialite\dbapi2.pyc", line 27, in <module>
File "pyspatialite\_spatialite.pyc", line 12, in <module>
File "pyspatialite\_spatialite.pyc", line 10, in __load
ImportError: DLL load failed: La procédure spécifiée est introuvable.
in_load signifies that the compilator failed to found a DLL but which one ? Any help/information will be helpful.
PS: this issue is related to one I already posted : https://gis.stackexchange.com/questions/73274/problems-with-py2exe-shapely-and-fiona
EDIT 1
More informations, my build.py (i.e setup.py)
from distutils.core import setup
import py2exe
import matplotlib
opts = {'py2exe':{"bundle_files":3,
"includes":["matplotlib",
"numpy",
"sip",
"PyQt4.QtCore",
"PyQt4.QtGui",
"osgeo",
"ctypes",
"os",
"sys",
"matplotlib.backends.backend_tkagg",
"pyspatialite"],
"excludes":['_gtkagg', '_tkagg', '_agg2',
'_cairo', '_cocoaagg',
'_fltkagg', '_gtk', '_gtkcairo', ],
'dll_excludes': ['libgdk-win32-2.0-0.dll',
'libgobject-2.0-0.dll',
'mswsock.dll',
'powrprof.dll'],
'packages':["win32api","pyspatialite"]
}
}
setup(name='Application OH_FET',
version='1.0',
windows=["OH_T_1.py"],
data_files=matplotlib.get_py2exe_datafiles(),
options=opts,
zipfile=None
)
Related
I used py2exe to build an exe of a program that uses scipy and numpy and I get the next error in the log file when I tried to run the program.
Traceback (most recent call last):
File "GLP2-e Admin.pyw", line 24, in <module>
File "C:\Python34\lib\site-packages\scipy\ndimage\__init__.py", line 161, in <module>
from .filters import *
File "C:\Python34\lib\site-packages\scipy\ndimage\filters.py", line 37, in <module>
from scipy.misc import doccer
File "C:\Python34\lib\site-packages\scipy\misc\__init__.py", line 51, in <module>
from scipy.special import comb, factorial, factorial2, factorialk
File "C:\Python34\lib\site-packages\scipy\special\__init__.py", line 629, in <module>
from .basic import *
File "C:\Python34\lib\site-packages\scipy\special\basic.py", line 18, in <module>
from . import orthogonal
File "C:\Python34\lib\site-packages\scipy\special\orthogonal.py", line 101, in <module>
from scipy import linalg
File "C:\Python34\lib\site-packages\scipy\linalg\__init__.py", line 190, in <module>
from ._decomp_update import *
File "<loader>", line 10, in <module>
File "<loader>", line 8, in __load
ImportError: (No module named 'scipy.linalg.cython_blas') 'Y:\\Factory\\GLP2-e Admin (Todos los archivos)\\Compilaciones\\Versión 2.1\\dist\\scipy.linalg._decomp_update.pyd'
I have tried some thing like put my setup.py file like this:
options ={
'py2exe': {
'bundle_files' : 3,
r'includes':[r'scipy.sparse.csgraph._validation',
r'scipy.special._ufuncs_cxx',],
'packages' : ['encodings'],
}
},
But it doesn't work and I still get that error.
I don't know what to do to solve this issue...
Hope you can help me.
Thanks.
I have been solve the issue adding in the "includes" section of my setup.py all the files that the log file return me as missing. After 7 files, the program run without any error.
I use pyqt4 to write a program to get some data from website and save as json
import json
import sys
from PyQt4 import QtGui
from PyQt4 import QtCore
from pip._vendor.requests import RequestException
import requests
...
content_debt = requests.get(debt_url+self.name)
debt_str= content_debt.text
debtf = open(self.name+".json",'wb')
debtf.write(debt_str)
debtf.close()
content_ind = requests.get(ind_url+self.name)
ind_str = content_ind.text
indf = open(self.name+".json",'wb')
indf.write(ind_str)
indf.close()
run well,so I tried to put it into an exe by py2exe
from distutils.core import setup
import py2exe
import sys
#this allows to run it with a simple double click.
sys.argv.append('py2exe')
py2exe_options = {
"includes": ["sip"],
"dll_excludes": ["MSVCP90.dll",],
"compressed": 1,
"optimize": 2,
"ascii": 0,
"bundle_files": 1
}
setup(
name = 'Search',
version = '1.0',
windows = ['main.py',],
zipfile = None,
options = {'py2exe': py2exe_options}
)
open the main.exe,In my computer it do well,but another computer get a error
Traceback (most recent call last):
File "main.py", line 6, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "pip\__init__.pyo", line 15, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "pip\vcs\subversion.pyo", line 9, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "pip\index.pyo", line 30, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "pip\wheel.pyo", line 35, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "pip\_vendor\distlib\scripts.pyo", line 14, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "pip\_vendor\distlib\compat.pyo", line 31, in <module>
ImportError: cannot import name HTTPSHandler
Anyone know how to fix this?
I want to use py2exe to pack a python file.
from distutils.core import setup
from glob import glob
import scipy
import numpy
import py2exe
import matplotlib
import wx
import sys
setup(
windows=["practice.py"],
options={"py2exe":
{"dll_excludes":["libiomp5md.dll",
"OLEAUT32.dll",
"USER32.dll",
"IMM32.dll",
"ole32.dll",
"MSVCP90.dll",
"SHELL32.dll",
"RPCRT4.dll",
"COMDLG32.dll",
"WSOCK32.dll",
"COMCTL32.dll",
"ADVAPI32.dll",
"WS2_32.dll",
"WINSPOOL.DRV",
"GDI32.dll",
"WINMM.dll",
"KERNEL32.dll",
"msvcm90.dll",
"msvcp90.dll",
"msvcr90.dll",
'libgdk-win32-2.0-0.dll',
'libgobject-2.0-0.dll'],
"includes" : [ "matplotlib.backends",
"matplotlib.backends.backend_qt4agg",
"pylab",
"numpy",
"wx",
"scipy",
"matplotlib.backends.backend_tkagg"],
'excludes':['_gtkagg',
'_tkagg',
'_agg2',
'_cairo',
'_cocoaagg',
'_fltkagg',
'_gtk',
'_gtkcairo']
}
},
data_files=matplotlib.get_py2exe_datafiles()
)
However,when I open the .exe, it reported as following
Traceback (most recent call last):
File "practice.py", line 1, in <module>
File "matplotlib\__init__.pyc", line 180, in <module>
File "matplotlib\cbook.pyc", line 33, in <module>
File "numpy\__init__.pyc", line 168, in <module>
File "numpy\add_newdocs.pyc", line 13, in <module>
File "numpy\lib\__init__.pyc", line 18, in <module>
File "numpy\lib\polynomial.pyc", line 19, in <module>
File "numpy\linalg\__init__.pyc", line 50, in <module>
File "numpy\linalg\linalg.pyc", line 29, in <module>
File "numpy\linalg\lapack_lite.pyc", line 12, in <module>
File "numpy\linalg\lapack_lite.pyc", line 10, in __load
ImportError: DLL load failed: can't find specific modulus.
64bit windows8 python2.7.9
I have searched in Stackoverflow and find some answers, however, it doesn't work.
Is your numpy installation ok?
"numpy\linalg\linalg.pyc", line 29 is trying to load
from numpy.linalg import lapack_lite, _umath_linalg
In my installation, I have lapack_lite.pyd and _umath_linalg.pyd there.
But it looks like your numpy is somehow expecting lapack_lite.pyc. I do not know why they are different but perhaps re-installing the numpy will help?
Numpy usually behaves very well with py2exe.
I'd wish to compile my program wrote in Python 3.2 with Pygame 1.9.5. But I'm a beginner with cx_Freeze and I've no idea how to manage with the complex structure... I mean :
My folder is like that :
gamefolder:
lib:
Menu.py (lauch the program)
level.py
othermodules.py
...
data:
Level1.png
otherspictures.png
So I tried to compile but I always get an error when I lauch Main.exe, indeed I think pygame is not load and also the path are not really clear.
I hope there's a solution, and that with such a structure it will not be impossible because I'd rather not rewrote each path in the scripts ...
Further informations :
the setup.py script is in lib folder and looks like that:
from cx_Freeze import setup, Executable
setup(
name = "Resets",
version = "1.0",
description = "Jeu de plateforme - Projet ISN 2014",
executables = [Executable("Menu.py")]
)
And i get this error when I launch the Menu.exe :
Traceback (most recent call last):
File "C:\Python32\lib\site-packages\pygame\__init__.py", line 117, in <module>
try: import pygame.display
File "ExtensionLoader_pygame_display.py", line 22, in <module>
File "ExtensionLoader_pygame_display.py", line 14, in __bootstrap__
File "ExtensionLoader_pygame_surface.py", line 22, in <module>
File "ExtensionLoader_pygame_surface.py", line 14, in __bootstrap__
ImportError: No module named _view
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Python32\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 2
7, in <module>
exec(code, m.__dict__)
File "Menu.py", line 8, in <module>
File "C:\Python32\lib\site-packages\pygame\__init__.py", line 118, in <module>
except (ImportError,IOError):display=MissingModule("display", geterror(), 1)
File "C:\Python32\lib\site-packages\pygame\__init__.py", line 61, in __init__
self.warn()
File "C:\Python32\lib\site-packages\pygame\__init__.py", line 85, in warn
warnings.warn(message, RuntimeWarning, level)
File "C:\Python\32-bit\3.2\lib\warnings.py", line 18, in showwarning
File "C:\Python\32-bit\3.2\lib\warnings.py", line 25, in formatwarning
File "C:\Python\32-bit\3.2\lib\linecache.py", line 15, in getline
File "C:\Python\32-bit\3.2\lib\linecache.py", line 41, in getlines
File "C:\Python\32-bit\3.2\lib\linecache.py", line 127, in updatecache
File "C:\Python\32-bit\3.2\lib\codecs.py", line 300, in decode
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x90 in position 2: invalid
start byte
I already try with import pygame._view and import re but it doesn't work too...
Finally I succeeded, it was very simple !
I added import pygame._view in each script. And I copied the data folder into the folder (after being compiled).
So I'm trying to package a python script into an exe that can run on a Windows machine without needing a python install. I'm running WIn7 & my application uses pywin32 & the launcher is a file called console.py which takes in a couple of command line arguments and executes another script
I created a setup.py file upon which I ran python setup.py build, with the following setup file
from cx_Freeze import setup, Executable
setup(
name = "OneNote Email Notifications",
version = "0.1",
description = "An email notifier for OneNote",
executables = [Executable("console.py")]
)
That returned the following error,
Traceback (most recent call last):
File "C:\Python32\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 2
7, in <module>
exec(code, m.__dict__)
File "console.py", line 1, in <module>
File "C:\Users\Varun\Desktop\My Dropbox\OnePy\OM\Notifications v0.2\notificati
ons.py", line 1, in <module>
import application
File "C:\Users\Varun\Desktop\My Dropbox\OnePy\OM\Notifications v0.2\applicatio
n.py", line 1, in <module>
import ApplicationServer
File "C:\Users\Varun\Desktop\My Dropbox\OnePy\OM\Notifications v0.2\Applicatio
nServer.py", line 5, in <module>
win32com.client.gencache.Rebuild()
File "C:\Python32\lib\site-packages\win32com\client\gencache.py", line 649, in
Rebuild
_SaveDicts()
File "C:\Python32\lib\site-packages\win32com\client\gencache.py", line 65, in
_SaveDicts
f = open(os.path.join(GetGeneratePath(), "dicts.dat"), "wb")
File "C:\Python32\lib\site-packages\win32com\client\gencache.py", line 141, in
GetGeneratePath
f = open(fname,"w")
IOError: [Errno 2] No such file or directory: 'C:\\Users\\Varun\\Desktop\\My Dro
pbox\\OnePy\\OM\\Notifications v0.2\\build\\exe.win-amd64-3.2\\library.zip\\win3
2com\\gen_py\\__init__.py'
so I figured perhaps there was an issue reading into the zipfile and decided to run build without creating library.zip. So I changed setup.py to
from cx_Freeze import setup, Executable
setup(
name = "OneNote Email Notifications",
version = "0.1",
description = "An email notifier for OneNote",
options = {"build_exe": {
"create_shared_zip": False,
"append_script_to_exe": True,
"include_in_shared_zip": False,
}
},
executables = [Executable("console.py")]
)
and now I get the following error message:
Traceback (most recent call last):
File "C:\Python32\lib\site-packages\cx_Freeze\initscripts\Console3.py", line 2
7, in <module>
exec(code, m.__dict__)
File "console.py", line 1, in <module>
File "C:\Users\Varun\Desktop\My Dropbox\OnePy\OM\Notifications v0.2\notificati
ons.py", line 1, in <module>
import application
File "C:\Users\Varun\Desktop\My Dropbox\OnePy\OM\Notifications v0.2\applicatio
n.py", line 1, in <module>
import ApplicationServer
File "C:\Users\Varun\Desktop\My Dropbox\OnePy\OM\Notifications v0.2\Applicatio
nServer.py", line 5, in <module>
win32com.client.gencache.Rebuild()
File "C:\Python32\lib\site-packages\win32com\client\gencache.py", line 649, in
Rebuild
_SaveDicts()
File "C:\Python32\lib\site-packages\win32com\client\gencache.py", line 65, in
_SaveDicts
f = open(os.path.join(GetGeneratePath(), "dicts.dat"), "wb")
File "C:\Python32\lib\site-packages\win32com\client\gencache.py", line 141, in
GetGeneratePath
f = open(fname,"w")
IOError: [Errno 2] No such file or directory: 'C:\\Users\\Varun\\Desktop\\My Dro
pbox\\OnePy\\OM\\Notifications v0.2\\build\\exe.win-amd64-3.2\\console.exe\\win3
2com\\gen_py\\__init__.py'
Try including the win32com.gen_py package.
You can always look in the created zip and see if the directory exists (or as you have done - don't zip until everything works well).
Change to the following
#....
executables = [Executable("console.py", packages=[''win32com.gen_py])]
#....