简体   繁体   中英

py2exe can't find .py

Sorry if this is a really stupid question,
How do I get the py2exe to find the module I wish to convert?
I keep getting this error:

C:\Python27\lib\distutils\dist.py:267: UserWarning: Unknown distribution option: 'dist_dir'
  warnings.warn(msg)
running py2exe
creating C:\Users\David\workspace\setup\src\dist
*** searching for required modules ***
error: Pygame.py: No such file or directory

I looked up as many Pygame to .exe tutorials or problems others have had, but their problem seemed to occur AFTER they created a .exe file...
I can't even get it to create one.
I used the exact same code as the one found on http://pygame.org/wiki/Pygame2exe except that I changed:

class BuildeExe:
 def __init__(self):
     #Name of starting .py
     self.script = "MyApps.py"

into

class BuildExe:
 def __init__(self):
     #Name of starting .py
     self.script = "Pygame.py"

My Pygame.py exists in "C:\\Users\\"username"\\workspace\\pygame\\src". Please help.

you can try putting this in a .py file:

from distutils.core import setup
import py2exe

setup(console=['hello.py'])

such as how they do in this tutorial. Then all you have to do is oppen up cmd.exe and cd to your "C:\\Users\\"username"\\workspace\\pygame\\src" and type:

python setup.py py2exe

or you can changed the setup.py to whatever .py file you saved the above code in. (within the same directory as you gave)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM