Hi, ich habe einen Code geschrieben den auf drei Files verteilt, wie kann ich eine exe datei daraus machen? Habe py2exe versucht hat nicht geklappt, sprich doch hat es lies sich aber nicht erfolgreich öffnen. Danach hab ich den pyinstaller versucht, bei dem kam ich aber nach dem erstellen der .spec datei nicht mehr weiter, nach einer weile sogar nicht mal mehr dort hin :S
was ich mich frage ist, das ich bei den ganzen tutorials immer nur beispiele für das machen einer exe aus EINER datei kriege. Muss man wenn man bei den "programmen" py2exe oder pyinstaller die dateinamen angeben muss, dann auch die anderen angeben oder holt es die alleine???
bitte helft mir wäre super dankebar
Grüsse
Queztapotel
Python Scripte zu exe
- cofi
- Python-Forum Veteran
- Beiträge: 4432
- Registriert: Sonntag 30. März 2008, 04:16
- Wohnort: RGFybXN0YWR0
Fehlermeldungen und Code, bitte, da meine Kristallkugel gerade streikt.
Michael Markert ❖ PEP 8 Übersetzung ❖ Tutorial Übersetzung (3.x) ⇒ Online-Version (Python 3.3) ❖ Deutscher Python-Insider ❖ Projekte
-
- User
- Beiträge: 13
- Registriert: Freitag 27. November 2009, 14:47
hehe sorry stimmt, des komische ist das es scriptmässig, also doppelklick auf main.py, einwandfrei funktioniert
Fehlermeldung eins:
C:\Python25\python.exe: can't open file 'setup.py': [Errno 2] No such file or directory
Fehlermeldung zwei:
C:\Python25\Pong\Tuxballmod>C:\Python25\pyinstaller-1.3\Build.py main.py
Traceback (most recent call last):
File "C:\Python25\pyinstaller-1.3\Build.py", line 839, in <module>
build(sys.argv[1])
File "C:\Python25\pyinstaller-1.3\Build.py", line 76, in build
exec open(spec, 'r').read()+'\n'
File "<string>", line 3, in <module>
File "C:\Python25\pygame.py", line 4, in <module>
from pygame.locals import *
ImportError: No module named locals
Code: Alles auswählen
# -*- coding: UTF-8 -*-
import os, sys
import pygame
import ball
import players
from pygame.locals import *
from pygame.rect import *
def main():
#initalize
pygame.init()
#Copyright
logo = "Copyright by Will"
fonty = pygame.font.SysFont("None", 12)
copy = fonty.render(logo, 1, (255,255,255))
copyright = copy.get_rect()
copyright.x = 730
copyright.y = 593
#create the display
screen = pygame.display.set_mode((800,600))
pygame.display.set_caption("Pong")
pygame.mouse.set_visible(1)
pygame.key.set_repeat(1, 30)
white = (255,255,255)
width = 5
#Create ball/players
pball = ball.Ball(screen)
bats = players.Players(screen)
#show the screen longer than a frame
clock = pygame.time.Clock()
running = 1
#init the lives/points
lives = 5
rightpointed = 0
leftpointed = 0
while running:
clock.tick(30)
screen.fill((0, 0, 0))
#scoreboard
font = pygame.font.SysFont("None", 35)
score = "%d : %d" % (leftpointed, rightpointed)
image = font.render(score, 1, (255,255,255))
points = image.get_rect()
points.x = 375
points.y = 30
#draw the playarea
playarea = pygame.draw.polygon(screen, white, [(10, 10), (790, 10), (790, 590), (10, 590)], 5 )
middlline = pygame.draw.line(screen, white, (400,10), (400,590), width)
middlline.inflate_ip(width,20)
#draw the bats/ball
pball.draw()
bats.drawleft()
bats.drawright()
#move the ball/bats
pball.move()
#limiting the zone where the ball could be while playing, that include the playerbats
#pay attention the ballrebound referring to the bat should be adjusted (1:1) to the ballspeed
if pball.x == 770 and pball.y <= bats.ry and pball.y >= bats.rx:
pball.xdir *= -1
if pball.x == 30 and pball.y <= bats.ly and pball.y >= bats.lx:
pball.xdir *= -1
if pball.y <= 10 or pball.y >= 575:
pball.ydir *= -1
#if the ball gets out of the horizontalfield
#the player which lost the ball lose one life
#after five outs the game is over
if pball.x <= 15:
lives -= 1
rightpointed += 1
pball.x = 400
pball.y = 400
#quit the games if there were no lives left
if lives == 0:
pygame.event.post(pygame.event.Event(QUIT))
if pball.x >= 785:
lives -= 1
leftpointed += 1
pball.x = 400
pball.y = 400
#quit the games if there were no lives left
if lives == 0:
pygame.event.post(pygame.event.Event(QUIT))
for event in pygame.event.get():
if event.type == QUIT:
running = 0
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
pygame.event.post(pygame.event.Event(QUIT))
bats.moveright()
bats.moveleft()
#shows the scoreboard and also the copyright
screen.blit(image, points)
screen.blit(copy, copyright)
pygame.display.flip()
if __name__ == '__main__':
main()
Code: Alles auswählen
#player left
import os, sys
import pygame
from pygame.locals import *
class Players:
def __init__(self,surface):
self.screen = pygame.display.set_mode((800,600))
self.surface = surface
self.width = 6
self.white = (255,255,255)
#represent the lenght of the bats
self.rx = 150
self.ry = 250
self.lx = 150
self.ly = 250
self.speed = 10
#draw the left bat
def drawleft(self):
leftplayer = pygame.draw.line(self.surface, self.white, (25,self.lx), (25,self.ly), self.width)
leftplayer.inflate_ip(self.width,20)
#draw the right bat
def drawright(self):
rightplayer = pygame.draw.line(self.surface, self.white, (775,self.rx), (775,self.ry), self.width)
rightplayer.inflate_ip(self.width,20)
#the bats will move over adding or subracting numbers(x and y coordinates) to the lenght simultaneously
def moveright(self):
#unfortunately to have the keys variable twice is necessary, combined with
#the get_pressed it makes it possible to move both bats at the same time
keys = pygame.key.get_pressed()
if keys[pygame.locals.K_UP]:
self.rx -= self.speed
self.ry -= self.speed
if self.rx <= 7:
self.ry += self.speed
self.rx += self.speed
elif keys[pygame.locals.K_DOWN]:
self.rx += self.speed
self.ry += self.speed
if self.ry >= 593:
self.ry -= self.speed
self.rx -= self.speed
def moveleft(self):
keys = pygame.key.get_pressed()
if keys[pygame.locals.K_w]:
self.lx -= self.speed
self.ly -= self.speed
if self.lx <= 7:
self.ly += self.speed
self.lx += self.speed
elif keys[pygame.locals.K_s]:
self.lx += self.speed
self.ly += self.speed
if self.ly >= 593:
self.ly -= self.speed
self.lx -= self.speed
Code: Alles auswählen
#Ball
import os, sys
import pygame
from pygame.locals import *
import main
class Ball:
def __init__(self,surface):
self.screen = pygame.display.set_mode((800,600))
self.surface = surface
self.white = (255,255,253)
self.bwidth = 0
self.radius = 6
self.x = 400
self.y = 400
#ballspeed
self.ydir = 10
self.xdir = 10
def draw(self):
self.ball = pygame.draw.circle(self.screen, self.white, (self.x,self.y), self.radius, self.bwidth)
def move(self):
self.x += self.xdir
self.y += self.ydir
C:\Python25\python.exe: can't open file 'setup.py': [Errno 2] No such file or directory
Fehlermeldung zwei:
C:\Python25\Pong\Tuxballmod>C:\Python25\pyinstaller-1.3\Build.py main.py
Traceback (most recent call last):
File "C:\Python25\pyinstaller-1.3\Build.py", line 839, in <module>
build(sys.argv[1])
File "C:\Python25\pyinstaller-1.3\Build.py", line 76, in build
exec open(spec, 'r').read()+'\n'
File "<string>", line 3, in <module>
File "C:\Python25\pygame.py", line 4, in <module>
from pygame.locals import *
ImportError: No module named locals
- cofi
- Python-Forum Veteran
- Beiträge: 4432
- Registriert: Sonntag 30. März 2008, 04:16
- Wohnort: RGFybXN0YWR0
Bitte lager den Code aus, bzw loesch ihn, denn das Problem ist, dass du py2exe und pyinstaller falsch benutzt, also lese da mal die entsprechende Dokumentation.
Michael Markert ❖ PEP 8 Übersetzung ❖ Tutorial Übersetzung (3.x) ⇒ Online-Version (Python 3.3) ❖ Deutscher Python-Insider ❖ Projekte