I make a game with python 2.5 and pygame.
but,I can't complete make.
because this errors occured.
C:\Python26\TypeType\src\dist\Main.exe:8: RuntimeWarning: use font: MemoryLoadLibrary failed loading pygame\font.pyd
Traceback (most recent call last):
File "Main.py", line 8, in <module>
File "pygame\__init__.pyo", line 70, in __getattr__
NotImplementedError: font module not available
Traceback (most recent call last):
File "Main.py", line 8, in <module>
File "pygame\sysfont.pyo", line 253, in SysFont
RuntimeError: default font not found 'freesansbold.ttf'
Perhaps I think that the reason is because it used an object called sysfont. (Because I had the programs that did not use sysfont on an execute file and was able to start with the PC which was not installed Python in)
What's wrong .
sorry I'm begginer.
EDIT
I can find Python2.5\Lib\site-packages\pygame\freesansbold.ttf
but same error occured..
Where may I copy freesansbold.ttf
A simple solution would be to simply load the font directly instead of using sysfont. Just use the pygame.font.Font class and directly load a ttf file. This will also make it easier to use py2exe, and you can choose exactly the font you want.
It looks like you don't have the freesansbold.ttf file on your computer in an accessible fonts folder. This font should have come with Pygame in the lib directory.
Check the installation folder for your copy of Pygame, and if it's there, modify your Python installation's font path to include that directory. If not, you'll need to find a copy or download a newer version of Pygame.
You probably found a solution but i want to give one for other.
Create you game with pygame. Then, unzip the librairy file.
Go to
PythonX.X\Lib\site-packages\pygame and copy freesansbold.ttf
Back to your library file that you unzipped and go to
library\pygame
Put freesansbold.ttf in and zip library.
Now, it's work ! :)
Related
When I run my py program it works the way I intended it to. If I am on a Linux box and build an executable using Pyinstaller, it builds without issue and executes without issue. I have scoured the Pyinstaller docs, git, etc. none of the posted fixes helped
I am still very new at python and feel like it might be a simple fix and might be over thinking the issue
Why can I no build a functional .exe on a windows based system using pyinstaller?
Windows 10 system
Pyinstaller version 3.2
Python version 3.5.2
This is a GUI program using appJar which is also up to date.
The file does build, but errors "Could not execute script"
EDIT
Not sure if this is best to edit in line like this but...
So studying the output and making adjustments, the issue seems to be appJar.py. For some reason it is missing assets, I am looking into it. The trouble is that I am still not used to looking at this kind of output and am not sure where to start.
C:\Users\_User_>C:\temp\fileCreatorGUI\fileCreatorGUI.exe
Traceback (most recent call last):
File "F:\Users\_User_\python_working\fileCreatorGUI.py", line 73, in <module>
app = gui()
File "C:\Users\_User_\AppData\Local\Programs\Python\Python35\lib\site-packages\appJar\appjar.py", line 509, in __init__
self.topLevel.wm_iconbitmap(self.appJarIcon)
File "C:\Users\_User_\AppData\Local\Programs\Python\Python35\lib\tkinter\__init__.py", line 1716, in wm_iconbitmap
return self.tk.call('wm', 'iconbitmap', self._w, bitmap)
_tkinter.TclError: bitmap "C:\temp\fileCreatorGUI\appJar\resources\icons\favicon.ico" not defined
Failed to execute script fileCreatorGUI
Edit 2
See answer below, but I was barking up the wrong tree on this one,
The Pyinstaller output chokes on the .dll's:
api-ms-win-core-console-l1-1-0.dll
api-ms-win-core-datetime-l1-1-0.dll
(There are like ~40 of these)
I added those .dll's to the python path, I declared them in the bianaries in the .spec file.
here is a truncated log:
2414 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-stdio-l1-1-0.dll
Traceback (most recent call last):
File "C:\Users\_USER_NAME\AppData\Local\Programs\Python\Python35-32\lib\site-pa
ckages\PyInstaller\depend\bindepend.py", line 695, in getImports
return _getImports_pe(pth)
File "C:\Users\_USER_NAME\AppData\Local\Programs\Python\Python35-32\lib\site-pa
ckages\PyInstaller\depend\bindepend.py", line 122, in _getImports_pe
dll, _ = sym.forwarder.split('.')
TypeError: a bytes-like object is required, not 'str'
2423 WARNING: Can not get binary dependencies for file: C:\Windows\system32\api-
ms-win-crt-heap-l1-1-0.dll
I tried the fix listed here:
https://github.com/pyinstaller/pyinstaller/pull/1981
but it did not seem to make a difference.
Someone recommended adding the sys.path.insert() route but it did not make a difference either way
I also tried this in a VM with windows 7, clean install, no change. My next step is to try to use Wine in Debian, but I don't really want to go that route. Any help would be appreciated. Thank you
Turns out this was an appJar/packaging issue, the pyinstaller was not looking in the correct directory for the assets. per the dev of appJar, I commented out two lines of code in the appJar.py, lines 508-509:
if self.platform == self.WINDOWS:
self.topLevel.wm_iconbitmap(self.appJarIcon)
More on the specifics here: https://github.com/jarvisteach/appJar/issues/84
I probably can fix this by using the --path argument with pyinstaller but for the moment, the issue is fully resolved
Now it's been like 3 days and I still don't manage. Maybe someone can help.
I want to send a control command to a midi device, via python, on a mac. Everywhere I see, the happy answer is to use pygame, but truth is that the pygame version on the mac lacks that functionality.
When I try run this two lines :
from pygame import midi
midi.init()
I get the following error:
Traceback (most recent call last):
File "midi_send.py", line 9, in <module>
midi.init()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site- packages/pygame/midi.py", line 71, in init
import pygame.pypm
ImportError: No module named pypm
I've looked and looked and all I find is dead ends.
Has anyone actually tried using pygame to write to a midiport, on a mac? is there an alternative that doesn't include getting stuck in some gcc compile error something replace line N of somemidi.o file somewhere in /etc/whatever/whatever?
Sorry for being frustrated...
You could try using the rtmidi-python library (or older and slightly different pyrtmidi) - both based on rtmidi which provides for straightforward sending of MIDI Control and Notes:
import rtmidi_python as rtmidi
midi_out = rtmidi.MidiOut()
midi_out.open_port(0)
midi_out.send_message([0x90, 48, 100]) # Note on
midi_out.send_message([0x80, 48, 100]) # Note off
Me and a team of friends created this game which I am now trying to run in linux,
We developed it using python 2.7 and Pygame in windows using Aptana studio and the code fully work when running through there.
When downloading it to linux It wouldn't load saying that it could not find files. I then tried running it via CMD in windows and there is the same error.
the error so far is
Traceback (most recent call last):
File "/home/user/Desktop/Raspberroids/mainmenu.py", line 144, in <module>
showMenu()
File "/home/user/Desktop/Raspberroids/mainmenu.py", line 107, in showMenu
menu.init(['Start','About','Quit'], surface)
File "/home/user/Desktop/Raspberroids/mainmenu.py", line 52, in init
self.create_strukture()
File "/home/user/Desktop/Raspberroids/mainmenu.py", line 73, in create_strukture
self.font = pygame.font.Font(self.font_path, self.fontsize)
IOError: unable to read font filename
And the source is at:
https://github.com/ryanteck/RasPiThon/tree/master/Raspberroids/Source%20Code
Happens on both 2.7 and 2.6
Can anyone help?
Your font path data/coders_crux/coders_crux.ttf is relative.
When you start your game from another directory than your source directory, pygame can't find the font.
A simple fix is to add the following lines to the top of your script (mainmenu.py):
import os
os.chdir(os.path.dirname(os.path.realpath(__file__)))
os.path.realpath(\__file__) will get the path to your script, and with os.chdir and os.path.dirname you change the current working directory to the directory of your script.
This way, the relative paths you use will work.
PyDev sets working directory and PYTHONPATH variable for your programs. It can also set console encoding to something different than OS defaults.
Add a print self.font_path statement before creating your Font object and see if path is OK. If it's relative path, you could also use os.path.abspath (see os.path docs for details) to get better understanding of what's going on.
I'm trying to convert a GUI program that uses .png images into an .exe using py2exe. It uses PIL to display these images. However, I'm having trouble with it converting. For some reason the .exe it makes wont run. Any ideas?
Edit
Error:
Traceback (most recent call last):
File "GUI1.2.8.py", line 454, in <module>
File "GUI1.2.8.py", line 13, in __init__
File "Tkinter.pyc", line 1643, in __init__
_tkinter.TclError: Can't find a usable init.tcl in the following directories:
{C:/Users/rectangletangle/lib/tcl8.5} {C:/Users/rectangletangle/lib/tcl8.5} C:/Users/lib/tcl8.5 {C:/Users/rectangletangle/library} C:/Users/library C:/Users/tcl8.5.8/library C:/tcl8.5.8/library
This probably means that Tcl wasn't installed properly.
The error seems to be completely unrelated (If I do anything wrong with py2exe, this is the error I usually get). Everything, work's until I import and use PIL. Also, I included PIL in my setup file.
Edit 2
This is a snippet showing how I implement the image.
self.image = ImageTk.PhotoImage(Image.open("image.png"))
self.imageLabel = Tkinter.Label(self, image=self.image)
self.imageLabel.grid(column=0, columnspan=4, row=0)
how do you display the image?
maybe PIL uses tcl/tk to img.show() and that's why you should include tcl in your py2exe setup script.
Just in case someone happens upon this problem, I was able to fix this error message by adding the init.tcl to my "data_files" section in my setup.py file:
setup(data_files=['D:\\Python27\\tcl\\tcl8.5\\init.tcl',
windows=["script":'myfile.py')])
I have created a simple program which uses pywin32. I want to deploy it as an executable, so I py2exe'd it. I also didn't want a huge amount of files, so I set bundle_files to 1 (meaning bundle everything together). However, when I attempt running it, I get:
Traceback (most recent call last):
File "pshelper.py", line 4, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "win32.pyc", line 8, in <module>
File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading win32ui.pyd
In my setup script, I tried doing packages=["win32ui"] and includes=["win32ui"] as options, but that didn't help. How can I get py2exe to include win32ui.pyd?
I don't have this problem if I don't ask it to bundle the files, so I can do that, for now, but I'd like to know how to get it to work properly.
Are you sure that the problem is that win32ui.pyd is not included? The stack trace isn't exactly the same as noted in the wiki, but check this out: http://www.py2exe.org/index.cgi/Py2exeAndWin32ui.
The work-around that has worked best so far is to simply re-implement the pywin32 functions using ctypes. That doesn't require another .pyd or .dll file so the issue is obviated.
Do care to try out PyInstaller? I've used it both on Windows 7 and Ubuntu 10.04 and it worked like magic, even when I compiled to .pyd on Windows.
I've been able to bundle all sorts of applications that I've developed with it.
I have the same problem trying to bundle psutil with py2exe. Here is what I found so far.
Traceback (most recent call last):
File "wx_gui.py", line 43, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "psutil\__init__.pyc", line 85, in <module>
File "zipextimporter.pyc", line 82, in load_module
File "psutil\_psmswindows.pyc", line 15, in <module>
File "zipextimporter.pyc", line 98, in load_module
ImportError: MemoryLoadLibrary failed loading _psutil_mswindows.pyd
I get this traceback when bundle_files = 3. zipfile may be specified or may be None, I still get the problem.
First, I thought this was a missing dll because of this page:
http://www.py2exe.org/index.cgi/ProblemsToBeFixed
I've copied all the dlls I found in Python27 into the same directory as the executable and added that directory path to os.environ['path']. That didn't worked.
Then I tried to import my package directly from site-packages.
I've replaced the whole sys.path of my compiled executable with my normal sys.path
sys.path = [r'C:\Python27\Lib\idlelib', ...]
I think the .pyd module got imported but Visual c++ threw me this really ugly error message:
Runtime Error!
Program: {path}.exe
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
I suggest you try to replace the whole sys.path to see if it is working. If it is, you could always make your single executable write the necessary module into a temp directory and add it to your path. If not, I feel like this problem is going to be hard to solve.