I have a single window/view enaml application (backend is PySide). I have packaged it to .exe using PyInstaller and it finishes successfully but when I run the executable it complains about the module which is in the .enaml file (I have already included the file and the parser in the .spec file, see below). Any thoughts on what goes wrong?
Here is the error from running the .exe file:
Traceback (most recent call last):
File "colEq.py", line 70, in <module>
from colEq import CaseView
ImportError: cannot import name CaseView
CaseView is defined in colEq.enaml file and the line referred to is:
with enaml.imports():
from colEq import CaseView`
My spec file has the following added beyond the default generated by PyInstaller:
a.datas+= [('colEq.enaml', 'colEq.enaml', 'DATA'),
('enaml\\core\\parser.py', parser_filepath, 'DATA')]
hiddenimports=[
"enaml",
"enaml.core.parse_tab.lextab",
"enaml.core.compiler_helpers",
"enaml.core.compiler_nodes",
"enaml.core.enamldef_meta",
"enaml.core.template",
"enaml.widgets.api",
"enaml.widgets.form",
"enaml.layout.api",
"enaml.stdlib.fields"
]
The platform is Python 2.7, x86, Win 10.
Related
Running an exe file which gives the below error on win10 build agent but not when the same script is ran on win10 locally:
16:06:50 Traceback (most recent call last):
16:06:50 File "C:\ProgramData\Anaconda3\envs\conda_venv\lib\site-packages\cx_Freeze\initscripts\__startup__.py", line 14, in run
16:06:50 File "C:\ProgramData\Anaconda3\envs\conda_venv\lib\site-packages\cx_Freeze\initscripts\Console.py", line 26, in run
16:06:50 File "package.py", line 98, in <module>
16:06:50 File "C:\ProgramData\Anaconda3\envs\conda_venv\lib\site-packages\testing_framework_sdk\__init__.py", line 15, in <module>
16:06:50 ModuleNotFoundError: No module named 'test_case_sdk'
Both files are ran from the same downloaded package with no changes in contents between the two.
Script does not require additional programs such as Python in order to operate.
Given that library files(.pyc) are contained within the downloaded directory I assume that this exe was generated using pyinstaller. python36.dll is also contained within the downloaded package
I don't have access to the source for this exe.
The file test_case_sdk.pyc does exist in the same directory for both the jenkins agent and local machine.
Do anyone know what is causing this discrepancy?
Edit: Turns out the filepath to test_case_sdk exceeded windows default limit of 260, this was why the module could not be found. I condensed the file path, error has gone.
I'm trying to create an exe out of a small Python Project. I have a main.py which imports packages from other subdirectories. After building the exe using pyinstaller when I run the executable I am facing import problems, its failing to identify the relative imports.
I tried modifying the .spec file but am unable to rectify the issue.
This is the current directory structure of my project
Link to project structure image
When I run the executable dist\cli\cli.exe it gives me this import error
Traceback (most recent call last):
File "cli.py", line 3, in <module>
from packages.__main__ import main
ImportError: No module named __main__
[5964] Failed to execute script cli
I'm trying use py2exe to compile an eye tracking experiment written in Python 2.7 (32-bit). The experiment uses the psychopy library. I wrote the experiment using the PyCharm IDE, and the experiment runs when I run it through the PyCharm IDE, using an interpreter in a virtual environment located at C:\Users\phil\Python_2.7_32-bit.
The experiment compiles without generating any errors when I enter the following command into the command prompt: C:\Users\phil\Python_2.7_32-bit\Scripts\python.exe C:\Users\phil\PycharmProjects\iTRAC\VisSearch\setup.py py2exe.
When I run the executable generated by the above py2exe command, I get this error:
Traceback (most recent call last):
File "VisualSearch.py", line 3, in <module>
File "psychopy\__init__.pyc", line 39, in <module>
File "psychopy\preferences\__init__.pyc", line 5, in <module>
File "psychopy\preferences\preferences.pyc", line 172, in <module>
File "psychopy\preferences\preferences.pyc", line 33, in __init__
File "psychopy\preferences\preferences.pyc", line 98, in loadAll
File "psychopy\preferences\preferences.pyc", line 146, in loadAppData
File "psychopy\preferences\configobj.pyc", line 583, in __getitem__
KeyError: 'builder'
My setup.py script is as follows:
from distutils.core import setup
import py2exe
setup(windows =['C:\Users\phil\PycharmProjects\iTRAC\VisSearch\VisualSearch.py'])
I've also tried using the following setup.py script with the same results:
from distutils.core import setup
import py2exe
setup(windows = [{'script':'C:\Users\phil\PycharmProjects\iTRAC\VisSearch\VisualSearch.py',
'options' : {'py2exe':{'includes':['psychopy'],
'compressed': True,
'bundle_files': 1,}}}])
I googled the error and came up with 0 results.
Can anybody tell me why I am running into this error?
This is probably a missing config/prefs file. PsychoPy uses the configobj library to read and validate preferences but my guess is that py2exe is only automatically packaging py/pyc files and needs to include the .spec files in the psychopy/preferences folder.
We're working on a Cocos2D game for Ludum Dare right now, and we are having issues packaging the game into an executable of some kind.
We have tried using py2exe, but it doesn't seem to work. I've read that py2exe often causes problems with this kind of libraries, but that they are usually workable. However, I've been doing some research for the last few hours and I can't seem to find a solution.
Here's the error message it gives us when executing the .exe, apparently it can't import the pyglet.resource module.
C:\Users\Jon\Documents\GitHubVisualStudio\King-of-the-Dungeon\King of the Dungeon\King of the Dungeon\dist>king_of_the_dungeon.exe
Traceback (most recent call last):
File "C:\Python34\lib\site-packages\pyglet\__init__.py", line 351, in __getattr__
return getattr(self._module, name)
AttributeError: 'NoneType' object has no attribute 'path'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "king_of_the_dungeon.py", line 1, in <module>
File "C:\Python34\lib\site-packages\cocos2d-0.6.3-py3.4.egg\cocos\__init__.py", line 71, in <module>
pyglet.resource.path.append(
File "C:\Python34\lib\site-packages\pyglet\__init__.py", line 357, in __getattr__
__import__(import_name)
ImportError: No module named 'pyglet.resource'
I just tried it myself and It works without problem. But I used cx_freeze.
See, Py2exe is old, no longer maintained, and overall you're better off using cx_freeze.
Download cx_freeze
create a setup.py file to create an exe:
import cx_Freeze
# Change "App" to the name of your python script
executables = [cx_Freeze.Executable("App.py")]
cx_Freeze.setup(
name="Sample Name",
version = "1",
options={"build_exe": {"packages":["pyglet", "cocos", "pygame"]}},
executables = executables
)
open cmd / terminal and build with ; python setup.py build
I just tried it with a simple game and it compiled with no trouble.
My script is working fine if I run it as Python from the command line.
I have converted the script to an .exe and am facing an issue with xlswrite. Below is the error output:
Traceback (most recent call last):
File "C:\Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27, in <module>
exec code in m.__dict__
File "loader.py", line 5, in <module>
ImportError: No module named xlsxwriter
I have used this video to create the .exe for my Python script.
How should I fix the import error?
I have only used cx_freeze a few times and was successful using these steps. You were possibly missing something in this. First, create a setup.py like so:
from cx_Freeze import setup, Executable
import sys
exe = Executable(
script="yourmodule.py",
base="Win32GUI",
)
setup(
name = "desiredname",
version = "1",
description = "example program",
executables = [exe]
)
Before running this, make sure that you have all non-default (built-in) modules and the setup.py file in the same folder as the yourmodule.py file. Then from the command line, run python setup.py build.