No module named 'pytmx' but pytmx is installed

1.3k views Asked by At

I am learning a Python Pygame tile-based game via a YouTube tutorial series https://www.youtube.com/watch?v=QIXyj3WeyZM

My code is identical to the code in the video. (I have checked many times for mistakes.)

When I run the program, I get this error:

  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'

It thinks I'm missing pytmx, but I installed it with Terminal pip install pytmx like in the video.

I was getting that error, so I uninstalled it and then reinstalled it again but there is the same error.

I'm running my code with Python 3.8 and the install path for pytmx is C:\Users\PC\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\pytmx

1

There are 1 answers

0
360yogi On

I uninstalled pytmx, pygame, and python and reinstalled it all again. Now it recognizes pytmx but I'm getting this huge TMX compression type: zstd is not supported error.

    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