I have a python 2.7 script that uses zmq and am trying to build a windows executable for it using py2exe. I get the following error:
Traceback (most recent call last):
File "console.py", line 4, in <module>
File "zmq\__init__.pyc", line 34, in <module>
File "zmq\backend\__init__.pyc", line 40, in <module>
File "zmq\backend\__init__.pyc", line 27, in <module>
File "zmq\backend\select.pyc", line 26, in select_backend
ImportError: No module named cython
I have tried py2exe --includes option, including cython and zmq with no success. I have also tried running the script with -O option and copying the resulting .pyo files to my dist directory. What am I missing?
This did the trick in my setup.py
import zmq.libzmq
setup(\
version='0.0.1',
options = {'py2exe' : {
'includes': [ 'zmq.backend.cython'],
"optimize": 2,
'packages': 'encodings'
},
},
data_files=[
('lib', (zmq.libzmq.__file__,))
],
console=['app.py'],
scripts = [ "app.py","file1.py","file2.py","file3.cfg"],
zipfile = 'None',
)
Hope it helps someone.
Related
I'm trying to create an *.exe file from my Python code.
This is my setup.py file:
from distutils.core import setup
import py2exe
import matplotlib
import sys
sys.setrecursionlimit(5000)
setup(
options={
'py2exe':
{
'includes': ['lxml.etree', 'lxml._elementpath', 'gzip','pandas'],
}
},
data_files=matplotlib.get_py2exe_datafiles(),
console=['test_zone_A_main.py'])
The code works fine on my machine, but when I'm running the exe on different machine , I'm getting the following error:
C:\Program Files (x86)\company\Campaign_Analyze>"C:\Program Files (x86)\sintec\Ca
mpaign_Analyze\dist\test_zone_A_main.exe"
Traceback (most recent call last):
File "test_zone_A_main.py", line 9, in <module>
File "calcs_performence.pyc", line 11, in <module>
File "test_config_cs.pyc", line 11, in <module>
File "pandas\__init__.pyc", line 13, in <module>
ImportError: C extension: DLL load failed: The specified module could not be found. not built. If you want to import pandas from the source directory, you may need to run 'python setup.py build_ext --inplace' to build the C extensions first.
Any ideas?
I'm converting a Python file to an .exe using py2exe like so:
from distutils.core import setup
import py2exe, sys, os
sys.argv.append('py2exe')
setup(
options = {'py2exe': {'bundle_files': 1, 'compressed': True}},
windows = [{'script': "myfile.py"}],
zipfile = None,
)
The .py file works just fine, but when I create the .exe, I get this message:
3 missing Modules
?pywin types imported from -
?win32api imported from platform, win32evtlogutil
?win32com imported from SCRIPT
And when I run the .exe, I get this error:
Traceback (most recent call last):
File "archiveFiles.py", line 83, in
File "archiveFiles.py", line 5, in putItIn
ImportError: No module named 'win32com'
Traceback (most recent call last):
File "archiveFiles.py", line 83, in
putItIn()
File "archiveFiles.py", line 5, in doThatStuff
import win32com.client as win32
ImportError: No module named 'win32com'
Any suggestions?
I want to generate an .exe file from a python script which includes the pywinauto module.
It builds fine, however when running the resulting dist\pywinauto_sample.exe, I get this error:
Traceback (most recent call last):
File "pywinauto_sample.py", line 2, in <module>
from pywinauto import application
File "pywinauto\application.pyc", line 68, in <module>
File "pywinauto\controlactions.pyc", line 45, in <module>
File "pywinauto\tests\__init__.pyc", line 128, in <module>
File "pywinauto\tests\__init__.pyc", line 114, in __init_tests
ImportError: No module named allcontrols
Here's my pywinauto_sample.py:
import pywinauto
from pywinauto import application
app = pywinauto.application.Application()
And here's my setup.py:
from distutils.core import setup
import py2exe
setup(console=['pywinauto_sample.py'])
I compile the program with:
python setup.py py2exe
Add this to your setup.py:
from distutils.core import setup
import py2exe
setup(
console=
[
'pywinauto_sample.py'
],
options=
{
"py2exe":
{
"includes":
[
"pywinauto.tests.truncation",
"pywinauto.tests.translation",
"pywinauto.tests.repeatedhotkey",
"pywinauto.tests.overlapping",
"pywinauto.tests.missingextrastring",
"pywinauto.tests.missalignment",
"pywinauto.tests.miscvalues",
"pywinauto.tests.leadtrailspaces",
"pywinauto.tests.comparetoreffont",
"pywinauto.tests.comboboxdroppedheight",
"pywinauto.tests.asianhotkey",
"pywinauto.tests.allcontrols",
]
}
}
)
Source: http://permalink.gmane.org/gmane.comp.python.py2exe/4663
When I try to build an exe using py2exe, it builds but when i try to run the exe it throws this error:
Traceback (most recent call last):
File "main.py", line 4, in <module>
File "OpenGL\GL\__init__.pyc", line 3, in <module>
File "OpenGL\GL\VERSION\GL_1_1.pyc", line 10, in <module>
File "OpenGL\platform\__init__.pyc", line 35, in <module>
File "OpenGL\platform\__init__.pyc", line 26, in _load
File "OpenGL\plugins.pyc", line 14, in load
File "OpenGL\plugins.pyc", line 28, in importByName
ImportError: No module named win32
It only does this when I use pyopengl, It builds and runs perfectly with pygame and almost any other library/module I have used.
My setup.py script looks like this:
from distutils.core import setup
import py2exe
setup(console=['main.py'])
I am on Windows 7 64bit
Actually, After another hour or so of searching I found the solution!
For anyone else who has this problem: http://www.py2exe.org/index.cgi/PyOpenGL
I am playing around with getting some basic stuff to work in Python before i go into full speed dev mode. Here are the specifics:
Python 2.5.4
PyQt4 4.4.3
SqlAlchemy 0.5.2
py2exe 0.6.9
setuptools 0.6c9
pysqlite 2.5.1
setup.py:
from distutils.core import setup
import py2exe
setup(windows=[{"script" : "main.py"}], options={"py2exe" : {"includes" : ["sip", "PyQt4.QtSql","sqlite3"],"packages":["sqlite3",]}})
py2exe appears to generate the .exe file correctly, but when i execute dist/main.exe i get this in the main.exe.log
Traceback (most recent call last):
File "main.py", line 18, in <module>
File "main.py", line 14, in main
File "db\manager.pyc", line 12, in __init__
File "sqlalchemy\engine\__init__.pyc", line 223, in create_engine
File "sqlalchemy\engine\strategies.pyc", line 48, in create
File "sqlalchemy\engine\url.pyc", line 91, in get_dialect
ImportError: No module named sqlite
I've been googling my heart out, but can't seem to find any solutions to this. If i can't get this to work now, my hopes of using Python for this project will be dashed and i will start over using Ruby... (not that there is anything wrong with Ruby, i just wanted to use this project as a good way to teach myself Python)
you need to include the sqlalchemy.databases.sqlite package
setup(
windows=[{"script" : "main.py"}],
options={"py2exe" : {
"includes": ["sip", "PyQt4.QtSql"],
"packages": ["sqlalchemy.databases.sqlite"]
}})
you need change to sqlalchemy.dialects.sqlite package
setup(
windows=[{"script" : "main.py"}],
options={"py2exe" : {
"includes": ["sip", "PyQt4.QtSql"],
"packages": ["sqlalchemy.dialects.sqlite"]
}})