I have a simple app, named test.py:
import tkinter
a=tkinter.Tk()
tkinter.Label(a,text='hello!').pack()
a.mainloop()
and I made a folder, named test. I active virtualenv, making setup.py and then 'python3 setup.py py2app'. finally, it shows 'Done!'(that means py2app worked fine without any problem.) but when I double click on my test.app in dist directory, it fails.(test error). do you know why this problem happens and how can I fix it?
this is the error message when I run distilled/test.app/Contents/MacOS/test:
Contents/MacOS/test ; exit;
Traceback (most recent call last):
File > "/Users/dariushmazlumi/Desktop/test/dist/test.app/Contents/Resources/__boo> t__.py", line 98, in <module>
_run()
File > "/Users/dariushmazlumi/Desktop/test/dist/test.app/Contents/Resources/__boo> t__.py", line 82, in _run
exec(compile(source, path, 'exec'), globals(), globals())
File > "/Users/dariushmazlumi/Desktop/test/dist/test.app/Contents/Resources/test.> py", line 1, in <module>
import tkinter
File "<frozen importlib._bootstrap>", line 961, in _find_and_load
File "<frozen importlib._bootstrap>", line 950, in > _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 646, in _load_unlocked
File "<frozen importlib._bootstrap>", line 616, in_load_backward_compatible
File "tkinter/__init__.pyc", line 36, in <module>
ValueError: character U+6573552f is not in range [U+0000; U+10ffff]
2017-09-06 14:08:17.090 test[1999:115511] test Error
logout
Saving session...
...copying shared history...
...saving history...truncating history files...
...completed.
Deleting expired sessions...99 completed.
[Process completed]
I'm using macOS sierra 10.12.
wow! I searched here about py2app error, and someone had same issue! here. downgrading to py2app 0.12 fixed my error.(may py2app was 0.14). thanks everyone how tried to help me.
Related
I am building an python project with Eel, and I'm trying to package my program to an exe with PyInstaller as instructed in the documentation. However, I get the following error when I open the .exe:
Error
Traceback (most recent call last):
File "hello.py", line 1, in <module>
import eel
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "eel\__init__.py", line 8, in <module>
File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "bottle.py", line 73, in <module>
AttributeError: 'NoneType' object has no attribute 'write'
I tried to use auto py-to-exe instead of Pyinstaller, but I got the same error. Finally, I tried to package the Eello world example from the Eel documentation to see if it was my program that was the issue, but I still got the same error. I found a similiar problem in a github issue, but I fail to see what I should attach to --add-data.
I am running Python 3.10.8 and Eel 0.14.0. I've now tried python 3.8.9 and python 3.9.13 without luck.
Update
Upon further investigation, I discovered that the error only occours when I attach --noconsole at the end of my cmd python -m eel hello.py web --onefile --noconsole . However, I want my app to work without a visible console.
One of the libraries you are using is attempting to write to sys.stdout and sys.stderr, which are set to None when you run pyinstaller with --windowed option.
You need to explicitly set sys.stderr and sys.stdout in your programs code as early as possible to a writeable object like an open file or an io buffer.
for example:
import sys
outfile = open("logfile.txt", "wt")
sys.stderr = outfile
sys.stdout = outfile
enter code hereI have to update an app I made on an Intel MacBook Pro to an Apple Silicon MacBook Pro. I am having problems after build the app file with py2app. I do not know if it also has to do with MacOS Ventura. I am using python 3.9 and have installed PortAudio with Homebrew
It works perfectly if I run it directly from Terminal but if I run the app I get this lines debugging
/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/MacOS/JFSTOOLS ; exit;
myuser#MacBook-Pro-myuser ~ % /Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/MacOS/JFSTOOLS ; exit;
Traceback (most recent call last):
File "sounddevice.pyc", line 71, in <module>
OSError: PortAudio library not found
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/__boot__.py", line 170, in <module>
_run()
File "/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/__boot__.py", line 84, in _run
exec(compile(source, path, "exec"), globals(), globals())
File "/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/JFSTOOLS.py", line 27, in <module>
import sounddevice as sd
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 627, in _load_backward_compatible
File "<frozen zipimport>", line 259, in load_module
File "sounddevice.pyc", line 83, in <module>
OSError: cannot load library '/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib': dlopen(/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib, 0x0002): tried: '/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib' (errno=20), '/System/Volumes/Preboot/Cryptexes/OS/Users/jose/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib' (no such file), '/Users/myuser/python/JFSTOOLS/dist/JFSTOOLS.app/Contents/Resources/lib/python39.zip/_sounddevice_data/portaudio-binaries/libportaudio.dylib' (errno=20)
2023-02-07 12:49:21.188 JFSTOOLS[55753:782196] Launch error
2023-02-07 12:49:21.188 JFSTOOLS[55753:782196] Launch error
See the py2app website for debugging launch issues
I have tried to update sounddevice, numpy, portaudio, etc but I am lost as I am not an expert. Any help would be appreciated
I'm trying to create a new virtualenvironment for some repos but seem to be running into a bunch if issues in my terminal, these are the errors I get:
zsh: /usr/local/bin/pip: bad interpreter: /usr/local/opt/python#2/bin/python2.7: no such file or directory
OR this issue:
ERROR: It thinks sys.prefix is '/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7' (should be '/Users/USERNAME_HERE/.virtualenvs/returns-backend')
ERROR: virtualenv is not compatible with this system or executable
I get this error when running: brew link --overwrite python from here
Linking /usr/local/Cellar/python/3.7.7... Error: Cannot link python
Another version is already linked: /usr/local/Cellar/python/3.7.6_1
I also get this issue when running the following command: pip3 install --upgrade pip from this comment
Traceback (most recent call last):
File "/usr/local/bin/pip3", line 11, in <module>
load_entry_point('pip==19.3.1', 'console_scripts', 'pip3')()
File "/usr/local/lib/python3.7/site-packages/pip/_internal/main.py", line 45, in main
command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/__init__.py", line 96, in create_command
module = importlib.import_module(module_path)
File "/usr/local/Cellar/python/3.7.6_1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/usr/local/lib/python3.7/site-packages/pip/_internal/commands/install.py", line 23, in <module>
from pip._internal.cli.req_command import RequirementCommand
File "/usr/local/lib/python3.7/site-packages/pip/_internal/cli/req_command.py", line 17, in <module>
from pip._internal.index import PackageFinder
ImportError: cannot import name 'PackageFinder' from 'pip._internal.index' (/usr/local/lib/python3.7/site-packages/pip/_internal/index/__init__.py)
I haven't touched the terminal in a long time (2+ years) and don't remember what I used to set these up as my documentation wasn't great last time when starting to code. I think I remember using brew before to set this stuff all up, but now I'm just worried about making any more changes that might break things even further.
Any help with commands that might not be as intrusive/possibly making this problem bigger?
I recently finished a project I have been working on for a while. I should present my work on the class' smart board which runs on linux. Taking in mind i can't download its modules because i don't have sudo permission nor it does have internet. So to get around this I decided to build it using pyinstaller. Everything seemed to work just fine in my device, but when i double checked in Virtual box this error pops up.
Traceback (most recent call last):
File "main.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller/loader/pyimod03_importers.py", line 540, in exec_module
File "matplotlib/__init__.py", line 923, in <module>
File "matplotlib/__init__.py", line 608, in matplotlib_fname
RuntimeError: Could not find matplotlibrc file; your Matplotlib install is broken
[8025] Failed to execute script main
So how can i build it so it works for all devices without the need of installation for any modules
matplotlib requires a config file names matplotlibrc to be found in one of 4 specific locations, the first one being the courant directory (see https://matplotlib.org/tutorials/introductory/customizing.html#the-matplotlibrc-file) One this file prepared as per need it can be embeeded in the exe by adding --add-data=matplotlibrc;. to the build command (replace ; with : for non-Windows systems)
I have freshly installed windows 10 and I am trying to run the following code.
import pyttsx3;
engine = pyttsx3.init();
engine.say("I will speak this text");
engine.runAndWait() ;
This use to work on my previous windows 10 installation but now it is giving me following error
Traceback (most recent call last):
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\__init__.py", line 44, in init
eng = _activeEngines[driverName]
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\weakref.py", line 137, in __getitem__
o = self.data[key]()
KeyError: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:/Users/ayush/Desktop/sample.py", line 2, in <module>
engine = pyttsx3.init();
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\__init__.py", line 46, in init
eng = Engine(driverName, debug)
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\engine.py", line 52, in __init__
self.proxy = driver.DriverProxy(weakref.proxy(self), driverName, debug)
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\driver.py", line 75, in __init__
self._module = importlib.import_module(name)
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 994, in _gcd_import
File "<frozen importlib._bootstrap>", line 971, in _find_and_load
File "<frozen importlib._bootstrap>", line 955, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 665, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 678, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\pyttsx3\drivers\sapi5.py", line 3, in <module>
import win32com.client
File "C:\Users\ayush\AppData\Local\Programs\Python\Python36\lib\site-packages\win32com\__init__.py", line 5, in <module>
import win32api, sys, os
ImportError: DLL load failed: %1 is not a valid Win32 application.
I am using python 3.6.6 64 bit on windows 10.
I have spent many hours trying different solutions like reinstalling python, tried python versions 3.5 and 3.7, reinstalling pyttsx3, also tried solutions given in few related questions but nothing is working.
Thanks in advance
Seems like win32api.pyd (which really is DLL) is not a win32 application. So I think it's loading 64bit drivers to 32bit runtime.
In this case, I will try to uninstall 64bit python, delete it's folder and install a 32bit version. I believe this will solve your problem, since you don't really need 64bit python.
Now the problem is in win32*.pyds, so it seems like your pyttsx3 is 32bit.
According to pypi.org, you can try pip install pypiwin32 to fix both win32 and win32api errors.
I tried installing Python 32 bits but customized with all options available such as a complete library, doing this worked wonders in breaking the errors! Just lauch the .exe launcher again, hit Modify and then just install every option!