I encounter the following error when freezing an app with esky. This occurs when using py2exe as the freezer module.
error: c:\docume~1\user\locals~1\temp\tmpkizl0t\scripts\my_script.py:
The process cannot access the file because it is being used by another process
The error only occurs when I use the sympy module in my code and add it to the packages in my setup.py file.
Here is the "options" part of my setup.py file:
options = {
'bdist_esky': {"freezer_module":"py2exe",
'includes':['encodings','Symbolic','matplotlib','Sequence','ClientTCP',
'XMLSequenceParser','XMLSequenceWriter','utils.widgets',
'pylab','ConfigParser','numpy','xml.etree.ElementTree','logging',
're','json','pylab','socket','struct','threading','traceback',
'utils.liststore','Reporter','tempfile', 'filecmp','os',
'cairo', 'pango', 'pangocairo', 'atk', 'gobject', 'gio','matplotlib.backends.backend_qt4agg','sympy'],
}
},
Problem below solved by answer from Thomas K:
If I use cx_freeze as the freezer module then the build completes but when I try to run the executable I get a similar error:
Traceback (most recent call last):
File "cx_Freeze__init__.py", line 743, in <module>
File "cx_Freeze__init__.py", line 332, in bootstrap
File "cx_Freeze__init__.py", line 359, in chainload
File "cx_Freeze__init__.py", line 729, in _chainload
File "C:\Python27\lib\site-packages\cx_Freeze\initscripts\Console.py", line 27
, in <module>
exec code in m.__dict__
File "c:\docume~1\user\locals~1\temp\tmpyisdxd\scripts\my_script.py", line 1447,
in <module>
NameError: name '__file__' is not defined
Has anyone come across this problem?
The error seems to indicate that some other process is using one of the SymPy files. Maybe just restarting the computer will fix it?
Related
So I finally got my python program working on my Mac (Catalina 10.15.4), but I am greeted with the following error when it is opened on another Mac (High Sierra 10.13.6.)
Could not import the PyAudio C module '_portaudio'.
Traceback (most recent call last):
File "/Volumes/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 355, in <module>
_run()
File "/Volumes/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 340, in _run
exec(compile(source, path, 'exec'), globals(), globals())
File "/Volumes/dist/Riff Gen.app/Contents/Resources/riffgen_v1.01.py", line 9, in <module>
from pysine import sine
File "pysine/__init__.pyc", line 14, in <module>
File "pysine/pysine.pyc", line 1, in <module>
File "pyaudio.pyc", line 116, in <module>
ImportError: dlopen(/Volumes/dist/Riff Gen.app/Contents/Resources/lib/python3.6/lib-dynload/_portaudio.so, 2): Symbol not found: ____chkstk_darwin
Referenced from: /Volumes/dist/Riff Gen.app/Contents/MacOS/../Frameworks/libportaudio.2.dylib (which was built for Mac OS X 10.15)
Expected in: /usr/lib/libSystem.B.dylib
in /Volumes/dist/Riff Gen.app/Contents/MacOS/../Frameworks/libportaudio.2.dylib
A simple tkinter test with various sounds and images works fine on the second machine, but not this script. I've tried adding all the packages manually, tried --nostrip, manually including 'libportaudio.2.dylib', and dozens of other ideas from countless outdated forums to no avail.
When the play function of my application is stripped, the app opens and crashes shortly thereafter - giving me the following error:
Traceback (most recent call last):
File "/Volumes/RG no audio/Riff Gen.app/Contents/Resources/__boot__.py", line 81, in <module>
_run()
File "/Volumes/RG no audio/Riff Gen.app/Contents/Resources/__boot__.py", line 66, in _run
exec(compile(source, path, 'exec'), globals(), globals())
File "/Volumes/RG no audio/Riff Gen.app/Contents/Resources/riffgen_v1.01.py", line 2037, in <module>
root.mainloop()
File "tkinter/__init__.pyc", line 1277, in mainloop
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xff in position 0: invalid start byte
Fatal Python error: PyEval_RestoreThread: NULL tstate
Current thread 0x00007fffa118e380 (most recent call first):
Abort trap: 6
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...none found.
[Process completed]
I have been using Python 3.6 and Py2App v0.13 because it is, unfortunately, the only version that has successfully packaged my program in a standalone package. Any version later than 0.13 gives me the following error even when bundling in alias mode:
Traceback (most recent call last):
File "/Users/Alex/Desktop/python_scripts/rhythm_generator/riffgen/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 420, in <module>
_run()
File "/Users/Alex/Desktop/python_scripts/rhythm_generator/riffgen/dist/Riff Gen.app/Contents/Resources/__boot__.py", line 414, in _run
exec(compile(source, script, 'exec'), globals(), globals())
File "/Users/Alex/Desktop/python_scripts/rhythm_generator/riffgen/riffgen_v1.01.py", line 7, in <module>
from tkinter import *
File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter/__init__.py", line 36, in <module>
import _tkinter # If this fails your Python may not be configured for Tk
ValueError: character U+6573552f is not in range [U+0000; U+10ffff]
I've seen a handful of people with similar errors to the one above, but the few solutions I've seen had no success.
I'm assuming there is a simple solution to both of these errors, but after a long two weeks of tinkering, I'm out of ideas. I just began programming and really want to continue to deploy GUI programs, so I am desperate to get this functional. Any help is greatly appreciated!!
Probably not an answer you were hoping for, but this might give you some ideas where to look:
check if you don't have multiple pythons installed. Make sure you run it with 3.6. (but you probably already did)
Check the modules installed on both PC's help('modules') in a python shell.
Check if the correct version of the modules is installed. Install the exact same versions pip install SomePackage==1.0.4
Symbol not found: ____chkstk_darwin seems to be a very mac related issue. I'd start searching there in combination with the modules you use in your script. This is the only post I found on stackoverflow and it suggests looking at the PATH settings; plaidml-setup uses the wrong lib path and gets OSErrors
i created exe using py2exe after that i facing this below error
i checked in lib directory and Queue.py is already present in that directory
please help me to resolve this issue
im using python 2.7
Traceback (most recent call last):
File "Game2048.py", line 12, in <module>
File "pynput\__init__.pyc", line 23, in <module>
File "pynput\keyboard\__init__.pyc", line 44, in <module>
File "pynput\keyboard\_win32.pyc", line 32, in <module>
File "pynput\_util\__init__.pyc", line 34, in <module>
File "six.pyc", line 203, in load_module
File "six.pyc", line 115, in _resolve
File "six.pyc", line 82, in _import_module
ImportError: No module named Queue
py2exe decides which modules to include in the final ZIP-file or executable by examining the import statements in those module(s) explicitly mentioned in setup.py. It then adds these imported modules to the dependencies of the executable and checks all import statements in these newly added modules to find further necessary modules and so on until no more new modules can be found in the imports.
Here, the module Queue is imported in a dynamical way, basically by calling something like __import__("Queue") which can't be automatically recognized by py2exe. Therefore the module isn't seen as necessary.
To solve this add an artificial dependency in a module which is already added to the executable:
if False:
import Queue
The code has no effect but py2exe sees the import statement and will follow it.
I am fairly new to Python and I need some help with an error message I am receiving. I am trying to make an exe file from a tkinter script with the help of py2exe, but I keep getting an AssertionError whenever I try to run the setup.py script. I have already created an exe file on my computer only a couple of days ago out of the same script without using tkinter. Creating this exe file was no problem. I am wondering if the error message occurs due to the fact that I have already created an exe file recently.
My setup.py script looks normal:
`# setup.py
from distutils.core import setup
import py2exe
setup(console=['MyScript.py'])`
Whenever I run it, I get this error:
AssertionError: distutils has already been patched by <class 'py2exe.patch_distutils.patch_distutils.<locals>.Distribution'>
The entire traceback looks like this:
Traceback (most recent call last):
File "C:\Dir\JetBrains\PyCharm Community Edition 2016.2.3\helpers\pycharm\pycharm_setup_runner.py", line 26, in <module>
exec (fh.read(), globals(), locals())
File "<string>", line 6, in <module>
File "C:\Dir\Python3\lib\distutils\core.py", line 134, in setup
ok = dist.parse_command_line()
File "C:\Dir\Python3\lib\distutils\dist.py", line 471, in parse_command_line
args = self._parse_command_opts(parser, args)
File "C:\Dir\Python3\lib\distutils\dist.py", line 527, in _parse_command_opts
cmd_class = self.get_command_class(command)
File "C:\Dir\Python3\lib\distutils\dist.py", line 817, in get_command_class
__import__ (module_name)
File "C:\Program Files (x86)\JetBrains\PyCharm Community Edition 2016.2.3\helpers\pycharm\pycharm_commands\pycharm_test.py", line 4, in <module>
from setuptools.command import test
File "C:\Dir\Python3\lib\site-packages\setuptools\__init__.py", line 14, in <module>
from setuptools.extension import Extension
File "C:\Dir\Python3\lib\site-packages\setuptools\extension.py", line 10, in <module>
from .dist import _get_unpatched
File "C:\Dir\Python3\lib\site-packages\setuptools\dist.py", line 39, in <module>
_Distribution = _get_unpatched(_Distribution)
File "C:\Dir\Python3\lib\site-packages\setuptools\dist.py", line 35, in _get_unpatched
"distutils has already been patched by %r" % cls
AssertionError: distutils has already been patched by <class'py2exe.patch_distutils.patch_distutils.<locals>.Distribution'>
Does anyone know a workaround to this problem? I am working in Python3.4.1.
Thank you so much for helping!
Try importing setuptools before you import py2exe.
It worked for me.
I'm using module transliterate.py from standard translit python libraries.
When I compile my GUI application, it raises the next error.
Traceback (most recent call last):
File "C:\Users\...\...\build\Rman\out00-PYZ.pyz\addobjectdialog", line 265, in OnTextName
File "C:\Users\...\...\build\Rman\out00-PYZ.pyz\core.utils", line 536, in translit
File "C:\Users\...\...\build\Rman\out00-PYZ.pyz\transliterate.utils", line 41, in translit
File "C:\Users\...\...\build\Rman\out00-PYZ.pyz\transliterate.utils", line 29, in ensure_autodiscover
File "C:\Users\...\...\build\Rman\out00-PYZ.pyz\transliterate.discover", line 27, in autodiscover
WindowsError: [Error 3] : 'C:\\...\\...\\AppData\\Local\\Temp\\_MEI11122\\transliterate\\contrib\\languages/*.*'
How I understand, I have to place
that lib somewhere within my application. But I just compile one .exe file, so wouldn't like to keep yet one file with my exe.
BTW, app is ran under Win 7 / 32bit.
Thanks.
That may be one of those libraries that you have to include explicitly. I know I had to do that from time to time with py2exe. See the following docs for more information:
http://pythonhosted.org/PyInstaller/#options-for-finding-imported-modules-and-libraries
I'm trying to create executable program with py2exe. I get the following error message when kinterbasdb is imported:
Traceback (most recent call last):
File "AlarmReporter.py", line 13, in <module>
File "zipextimporter.pyo", line 82, in load_module
File "kinterbasdb\__init__.pyo", line 119, in <module>
File "zipextimporter.pyo", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading kinterbasdb\_kinterbasdb.pyd
Here's my very basic setup.py for py2exe:
from distutils.core import setup
import py2exe
import sys
setup(
options={'py2exe': dict(bundle_files=1, optimize=2)},
console=['AlarmReporter.py'],
zipfile=None,
)
I'm having problem understanding the error message and have no idea how to fix it.
Try to exclude libfbclient dll
Error while transforming .py to .exe
If that doesn't work , try to use the new fdb driver (the future replacement of kinterbasdb)
http://permalink.gmane.org/gmane.comp.db.firebird.python/104
(it doesn't need compiling only the libfbclient.dll)
Another option is to use the pure driver that doesn't need no dll and no c generated binary
https://github.com/nakagami/pyfirebirdsql
But you will use it at your own risk ;)