• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
PaladinJohn

Problem creating an .exe with py2exe

4 posts in this topic

My problem seems like a pretty simple issue, but I don't have any idea how to go about fixing this. I'll show the problem and list the steps I've taken so far in order to fix it.

After creating a game using python 2.7, I tested the game and it worked flawlessly without any bugs. Deciding that I wanted to redistribute it to a few of my friends I looked up some info on what I would have to do and eventually found py2exe. After carefully following all of the directions and creating my .exe, it failed to run. Running it through command line I got the following errors:

[spoiler]footBallHell.exe:1: RuntimeWarning: import display: No module named _view
(ImportError: No module named _view)
footBallHell.exe:1: RuntimeWarning: import draw: No module named _view
(ImportError: No module named _view)
footBallHell.exe:1: RuntimeWarning: import image: No module named _view
(ImportError: No module named _view)
footBallHell.exe:1: RuntimeWarning: import pixelcopy: No module named _view
(ImportError: No module named _view)
footBallHell.exe:1: RuntimeWarning: import transform: No module named _view
(ImportError: No module named _view)
Traceback (most recent call last):
File "footBallHell.py", line 218, in <module>
File "pygame\__init__.pyc", line 70, in __getattr__
NotImplementedError: display module not available
(ImportError: No module named _view)[/spoiler]

(Although I'm sure it's obvious, the name of my program is footBallHell.)

So, clueless as to what to do next I searched up google and found this similar problem on the python forums:

[url="http://www.python-forum.org/pythonforum/viewtopic.php?f=15&t=26719"]http://www.python-fo...hp?f=15&t=26719[/url]

After reading that I dug around through the Python folder and went to:

C:\Python27\Lib\site-packages\pygame

and found a file listed as "_view.pyd"

I believed that this was the file in question that was missing so I copied it into the dist folder hoping it would solve the problem. Unfortunately, it didn't. So, afterwards I went and added it into the directory with the rest of the relevant files as well as the setup.py program I used to create the executable so the program read as follows:

[code]from distutils.core import setup
import py2exe

setup(console = ["footBallHell.py"],
author="XXXX",
author_email="XXXX",
data_files=[('.', ["attack.ogg",
"enemy.gif",
"Field.gif",
"football.gif",
"player.gif",
"save.ogg",
"tackle.ogg",
"freesansbold.ttf",
"_view.pyd"]
)]
)[/code]

After running the setup.py program, it did include the _view.pyd file in the dist folder, but still would not run.

So, I believe I either have the wrong file or there is something else I need to do in order to get the program to run. What I am asking is if there is any one out there that might know how to fix this issue, or, at worst, inform me of another way I can create an executable for Windows out of my python programs that I can distribute to my friends.
1

Share this post


Link to post
Share on other sites
[quote name='PaladinJohn' timestamp='1313116916' post='4848070']
-snip-[/quote]
Hi, I have written a game with Python too. It imports quite a lot of external modules (though pygame isn't one of them).
I don't have much experience with py2exe, though, as I use cx_freeze to distribute my app and it works perfectly. I made that choice over py2exe long ago, and I don't remember why exactly, but cx_freeze turned out to be better for my needs. I suggest you try it, and see if it works. Go there: [url="http://cx-freeze.sf.net"]http://cx-freeze.sf.net[/url]

I [i]might[/i] be able to help you with cx_freeze since I know the structure of its output better than that of py2exe.
(PS- If you're interested to see the final result for the game, you can [url="http://neoncobalt.free.fr/antennes/index_en.php#dl"]download it[/url]. The game itself is frozen with cx_freeze. Then, I made a tiny launcher with NSIS, so that I could bury all the DLLs inside the "data\bin" folder. That way, it's friendlier to the end-user that has just unzipped the game: they don't have to face a bunch of files with cryptic names.)

EDIT - Here is the structure of my setup.py: (sorry about the borked spaces)

[code]import sys
from cx_Freeze import setup, Executable

includefiles = []

if sys.platform.startswith('win'):
includefiles.append( ("win32\\dll", ".") ) # my custom dlls are there

options = {
"icon": 'win32/citronicon.ico',
"include_files": includefiles
}

mybase = None
if sys.platform.startswith('win'):
mybase = "Win32GUI"

cible_1 = Executable(
script = "main.py",
base = mybase,
compress = False,
copyDependentFiles = False,
)

setup(
name = "main",
version = "0.4",
description = u"game name",
author = "me",
options = {'build_exe':options},
executables = [cible_1]
)[/code]
0

Share this post


Link to post
Share on other sites
Your other option is to work from the PyGame's [url="http://pygame.org/wiki/Pygame2exe"]py2exe script[/url]
0

Share this post


Link to post
Share on other sites
Thank you both for your replies!

I looked at pygame's py2exe script before, but truth be told, I'm a fledgling in the world of programming, and admittedly know very little about the world of windows and how it actually runs programs. Looking over the script, while I understood some of it, other parts looked completely foreign even with comments. I feel uncomfortable using code that I don't at least understand what each part is supposed to be doing, and a lot of that code contains things that either look like they would be superfluous to my needs, or references stuff that I have no clue whether it's an example or is something that is actually needed. (Such as wildcards. Never heard of them before.)

I tried to find some more in depth documentation of that script, but I was unable to find any such thing.

Knackebrod,

I took a brief look at cx_freeze, and it seems that it's benefits include cross platform support. Your example setup.py was good, but I am still confused about some of the finer details of the script. At this point in time I'm not too worried about surface level changes such as including an icon or installer (Though I did appreciate it in the example so I now know how to do such things when I do put more effort into making a presentable program. I will be checking out NSIS in the future.) Right now I'm looking for a nitty gritty bare bones .exe that I can zip up, send to my friends, and have them delete the file after they're done playing around with it.

One thing that I would like to add that I found in my search for an answer was that someone with a similar problem was told that they can explicitly specify modules to include on the py2exe command line. Unfortunately, all the experience I've ever had with the command line I've learned since installing py2exe a few nights ago and the breadth of my experience with it is getting py2exe to run. I'm very nervous about tinkering around in command line as I don't want to accidentally blow my computer up, but would any one know a way to include the _view.pyd file on that same command line so it (hopefully) compiles into the .exe correctly?
0

Share this post


Link to post
Share on other sites
I got it to work! I'll detail what I did here so if any other clueless beginner stumbles upon these same errors and does a google search, they might be able to compile their game without any issue:

Firstly, to fix the _view problem, I was forced to put the following line of code into my main program (not the setup.py program) in order to call the _view.pyd so that py2exe actually finds it:

[code]import pygame._view[/code]

That line of code has absolutely no effect on the program itself.

Afterwards, I kept getting font errors despite making sure to include the font in the list of files. A brief search of the internet helped me to narrow down exactly which part of pygame's py2exe script was responsible for fixing the issue with the font, as well as the sound which was a problem I ran into afterwards. Simply copy/pasting the code from the script did not work, and instead thanks to some advice from the following blog: [url="http://thadeusb.com/weblog/2009/4/15/pygame_font_and_py2exe"]http://thadeusb.com/...font_and_py2exe[/url] I edited my setup.py script appropriately. (Please remember to import os in your setup.py script!)

Here is the final setup.py program I wound up with:

[code]from distutils.core import setup
import py2exe, os

origIsSystemDLL = py2exe.build_exe.isSystemDLL
def isSystemDLL(pathname):
if os.path.basename(pathname).lower() in ("sdl_ttf.dll", "libogg-0.dll"):
return 0
return origIsSystemDLL(pathname)
py2exe.build_exe.isSystemDLL = isSystemDLL

setup(console = ["footBallHell.py"],
author="XXXX",
author_email="XXXX",
data_files=[('.', ["attack.ogg",
"enemy.gif",
"Field.gif",
"football.gif",
"player.gif",
"save.ogg",
"tackle.ogg",
"freesansbold.ttf"]
)]
)[/code]
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0