没有安装名为“ pytmx”的模块,但安装了pytmx

时间:2020-07-19 19:08:33

标签: python python-3.x pygame pytmx

我正在通过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

1 个答案:

答案 0 :(得分:0)

我卸载了pytmxpygamepython,然后又重新安装了它们。现在它可以识别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