basti2

Pygame funktioniert nur in der Konsole, jedoch nicht als Skript

Guten Morgen zusammen.

Folgendes Problem.
Wenn ich in dem "Python 3.6.1 Shell" Fenster pygame importiere funktioniert alles, tue ich das ganze aber in einem Skript speichern mit der Endung .py und diesen ausführen kommt nur:

File "C:\Users\Basti\Desktop\pygame.py", line 1, in <module>
import pygame
File "C:\Users\Basti\Desktop\pygame.py", line 2, in <module>
pygame.init
AttributeError: module 'pygame' has no attribute 'init'

Das ist bisher nur bei pygame so das importieren von "socket", "time" ect. funktioniert.

Ich hoffe ihr könnt mir helfen, bei Google hab ich nichts finden können,
zumal ich auch nicht genau weiß wonach ich da suchen soll.

LG Basti
Auf Facebook teilen
Auf X (Twitter) teilen
Auf Reddit teilen
Auf Linkedin teilen

Content-ID: 335073

Url: https://administrator.de/forum/pygame-funktioniert-nur-in-der-konsole-jedoch-nicht-als-skript-335073.html

Ausgedruckt am: 28.04.2025 um 09:04 Uhr

132895
132895 13.04.2017 um 10:16:06 Uhr
Goto Top
Basti2
Basti2 13.04.2017 um 10:29:11 Uhr
Goto Top
also wenn ich print(sys.path) ausführe dann zeigt es mir unteranderem den Pfad zu dem Ordner "site-packages", in welchem pygame enthalten ist.
Snowman25
Snowman25 13.04.2017 um 12:03:22 Uhr
Goto Top
Auch, wenn du print(sys.path) in deiner pygame.py hast?
132895
132895 13.04.2017 aktualisiert um 13:35:51 Uhr
Goto Top
Dann Tippe ich mal das die falsche Python Version beim Ausführen als Skript Verwendung findet.
Basti2
Basti2 13.04.2017 aktualisiert um 15:05:47 Uhr
Goto Top
ja auch da.


ich hab python 3.6 installiert und hab dann mit "pip install pygame" pygame installiert.