我正在通过YouTube教程系列https://www.youtube.com/watch?v=QIXyj3WeyZM
学习基于Python Pygame磁贴的游戏我的代码与视频中的代码相同。 (我已经检查了很多次了。)
运行程序时,出现此错误:
File "C:\Users\PC\Desktop\letní hra\TILE TUTORIAL\main.py", line 6, in <module>
from sprites import *
File "C:\Users\PC\Desktop\letní hra\TILE TUTORIAL\sprites.py", line 3, in <module>
from tilemap import collide_hit_rect
File "C:\Users\PC\Desktop\letní hra\TILE TUTORIAL\tilemap.py", line 1, in <module>
import pytmx
ModuleNotFoundError: No module named 'pytmx'
它认为我缺少pytmx,但是我将其安装在终端pip install pytmx
中,就像视频中一样。
我遇到了该错误,因此我将其卸载,然后再次重新安装,但存在相同的错误。
我正在使用Python 3.8运行代码,pytmx的安装路径为C:\Users\PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pytmx
答案 0 :(得分:0)
我卸载了pytmx
,pygame
和python
,然后又重新安装了它们。现在它可以识别pytmx
了,但是我遇到了这个巨大的TMX compression type: zstd is not supported
错误。
TMX compression type: zstd is not supported.
Traceback (most recent call last):
File "C:\Users\PC\Desktop\letní hra\TILE TUTORIAL\main.py", line 130, in <module>
g = Game()
File "C:\Users\PC\Desktop\letní hra\TILE TUTORIAL\main.py", line 34, in __init__
self.load_data()
File "C:\Users\PC\Desktop\letní hra\TILE TUTORIAL\main.py", line 41, in load_data
self.map = TiledMap(path.join(map_folder, "test64.tmx"))
File "C:\Users\PC\Desktop\letní hra\TILE TUTORIAL\tilemap.py", line 22, in __init__
tm = pytmx.load_pygame(filename, pixelalpha=True)
File "C:\Users\PC\AppData\Local\Programs\Python\Python37\lib\site-packages\pytmx\util_pygame.py", line 141, in load_pygame
return pytmx.TiledMap(filename, *args, **kwargs)
File "C:\Users\PC\AppData\Local\Programs\Python\Python37\lib\site-packages\pytmx\pytmx.py", line 360, in __init__
self.parse_xml(ElementTree.parse(self.filename).getroot())
File "C:\Users\PC\AppData\Local\Programs\Python\Python37\lib\site-packages\pytmx\pytmx.py", line 391, in parse_xml
self.add_layer(TiledTileLayer(self, subnode))
File "C:\Users\PC\AppData\Local\Programs\Python\Python37\lib\site-packages\pytmx\pytmx.py", line 962, in __init__
self.parse_xml(node)
File "C:\Users\PC\AppData\Local\Programs\Python\Python37\lib\site-packages\pytmx\pytmx.py", line 1044, in parse_xml
raise Exception
Exception