# PermissionError \[Errno 13\] Permission denied Python 2023

**URL:** <https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360>\
**Category:** Python Help\
**Created:** [January 2, 2023, 4:02am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360 "2023-01-02T04:02:59Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dinzai](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/dinzai/32/10444_2.png) [@Dinzai](https://discuss.python.org/u/Dinzai)\
**Post date:** [January 2, 2023, 4:02am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/1 "2023-01-02T04:02:59Z")

</div>

To whom it may concern,  
Please read what I have to say before giving the usual response to this question. I have asked on multiple Discords after googling for Hours. I am to the point that i am writing on a Python forum to figure out what the issue could actually be. The screen shots linked will show that not only am I Admin on my PC, I also have enabled “Full Control” on the hard drive that the files are in. I have enabled every permission known to me. The files i am trying to read from the drive are indeed there, and the file location indeed does exist. I have no other editor open with those files, no excel, or Tiled program open. I have even ran Pycharm as Admin and get the same error. I have even gone as far as trying to open the files from my D: drive instead of my G: drive. I get the same error. All i am trying to accomplish is to open a “.tmx” from an export from Tiled to use what I made as a map in a pygame. I can send any and all Code relating to this in case my coding is the issue.

I also restarted the Computer multiple times in case the files did not close properly in Tiled.

As a new user, I can only upload one screenshot, I have several I need to share, so i am sharing the one that shows i am indeed an Admin so that can be cleared up that I have significant permissions

I appreciate you (anyone) taking the time to help me with this, especially near the holidays

 ![Desktop Screenshot 2023.01.01 - 20.43.10.99](https://us1.discourse-cdn.com/flex002/uploads/python1/original/2X/6/659c4c08f703d8163f5d9f8371d09660360722aa.jpeg)

---

<div class="post-metadata">

**Author:** ![Rosuav](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rosuav/32/3429_2.png) [@Rosuav](https://discuss.python.org/u/Rosuav)\
**Post date:** [January 2, 2023, 4:13am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/2 "2023-01-02T04:13:12Z")

</div>

If “the usual response” is “please post your code”, then I have read what you had to say and it’s still appropriate. Don’t post screenshots of code.

---

<div class="post-metadata">

**Author:** ![Dinzai](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/dinzai/32/10444_2.png) [@Dinzai](https://discuss.python.org/u/Dinzai)\
**Post date:** [January 2, 2023, 4:14am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/3 "2023-01-02T04:14:40Z")

</div>

What is the appropriate way to post my code?

---

<div class="post-metadata">

**Author:** ![Dinzai](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/dinzai/32/10444_2.png) [@Dinzai](https://discuss.python.org/u/Dinzai)\
**Post date:** [January 2, 2023, 4:31am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/4 "2023-01-02T04:31:23Z")

</div>

````python
  # This is my main.py 
from tiles import *
from settings import *

from spritesheet import *

pygame.init()
DISPLAY_W, DISPLAY_H = 480, 270
canvas = pygame.Surface((DISPLAY_W, DISPLAY_H))
window = pygame.display.set_mode(((DISPLAY_W, DISPLAY_H)))
running = True
clock = pygame.time.Clock()

def __init__ (self):
  self.Map_img = self.map.make_map()
  self.map_rect = self.Map_img.get_rect()
  self.Map_img = pygame.transform.scale(self.Map_img, (TILESIZE, TILESIZE))

while running:
  clock.tick(60)
  for event in pygame.event.get():
      if event.type == pygame.QUIT:
          running = False
      if event.type == pygame.KEYDOWN:
          pass

      canvas.fill((0, 180, 240)) # Fills the entire screen with light blue

      # canvas.blit(player_img, player_rect)
      window.blit(canvas, (0, 0))
      pygame.display.update()

  ```
````

---

<div class="post-metadata">

**Author:** ![Dinzai](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/dinzai/32/10444_2.png) [@Dinzai](https://discuss.python.org/u/Dinzai)\
**Post date:** [January 2, 2023, 4:32am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/5 "2023-01-02T04:32:12Z")

</div>

````python
   # This is my tile.py 
import pygame
import csv
import os
from pytmx.util_pygame import load_pygame

import settings

tmx_data = load_pygame("G:/Tiled/Game Python Files/Adjusted TileSet for MapEditor/Maps/Kanto Tiled Map Files")

#txtdata = load_pygame('G:/Tiled/Game Python Files/Adjusted TileSet for MapEditor/Text')

class Map:
   def __init__ (self, filename):
       self.data = []
       self.tilewidth = len(self.data[0])
       self.tileheight = len(self.data)
       self.width = self.tilewidth * settings.TILESIZE
       self.height = self.tileheight * settings.TILESIZE

class Tile(pygame.sprite.Sprite):
   def __init__ (self, pos, surface):
       super(). __init__ ()
       self.image = surface
       self.rect = self.image.get_rect(topleft=pos)

for layer in tmx_data.visible_layers:

   if hasattr(layer, 'data'):
       for x, y, surface in layer.tiles():
           pos = (x * 16, y * 16)
           Tile(pos=pos, surface=surface)

class TiledMap:
   def __init__ (self, filename):
       tm = pytmx.load_pygame(filename, pixelalpha=True)
       self.width = tm.width * tm.tilewidth
       self.height = tm.height * tm.tileheight
       self.tmxdata = tm

   def render(self, surface):
       ti = self.tmxdata.get_tile_image_by_gid
       for layer in self.tmxdata.visible_layers:
           if isinstance(layer, pytmx.TiledTileLayer):
               for x, y, gid, in layer:
                   tile = ti(gid)
                   if tile:
                       surface.blit(tile, (x * self.tmxdata.tilewidth,
                                           y * self.tmxdata.tileheight))

   def make_map(self):
       temp_surface = pygame.Surface((self.width, self.height))
       self.render(temp_surface)
       return temp_surface

class Camera:
   def __init__ (self, width, height):
       self.camera = pygame.Rect(0, 0, width, height)
       self.width = width
       self.height = height

   def apply(self, entity):
       return entity.rect.move(self.camera.topleft)

   def apply_rect(self, rect):
       return rect.move(self.camera.topleft)

   def update(self, target):
       x = -target.rect.centerx + int(settings.WIDTH / 2)
       y = -target.rect.centery + int(settings.HEIGHT / 2)

       # limit scrolling to map size
       x = min(0, x) # left
       y = min(0, y) # top
       x = max(-(self.width - settings.WIDTH), x) # right
       y = max(-(self.height - settings.HEIGHT), y) # bottom
       self.camera = pygame.Rect(x, y, self.width, self.height)

   ```
````

---

<div class="post-metadata">

**Author:** ![Dinzai](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/dinzai/32/10444_2.png) [@Dinzai](https://discuss.python.org/u/Dinzai)\
**Post date:** [January 2, 2023, 4:32am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/6 "2023-01-02T04:32:58Z")

</div>

````python
    # This is my spritesheet.py   
import pygame
import json

class Spritesheet:
    def __init__ (self, filename):
        self.filename = filename
        self.sprite_sheet = pygame.image.load(filename).convert()
        self.data = self.filename.replace('png', 'json', 'tmx', 'txt')
        with open(self.data, 'r', encoding='utf-8') as f:
            self.data = json.load(f)
        f.close()

    def get_sprite(self, x, y, w, h):
        sprite = pygame.Surface((w, h))
        sprite.set_colorkey((0, 0, 0))
        sprite.blit(self.sprite_sheet, (0, 0), (x, y, w, h))
        return sprite

    def parse_sprite(self, name):
        sprite = self.data['frames'][name]['frame']
        x, y, w, h = sprite["x"], sprite["y"], sprite["w"], sprite["h"]
        image = self.get_sprite(x, y, w, h)
        return image

    ```
````

---

<div class="post-metadata">

**Author:** ![Dinzai](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/dinzai/32/10444_2.png) [@Dinzai](https://discuss.python.org/u/Dinzai)\
**Post date:** [January 2, 2023, 4:33am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/7 "2023-01-02T04:33:39Z")

</div>

```python
    # This is my settings.py 
 import pygame
from spritesheet import *
vec = pygame.math.Vector2

WIDTH = 341
HEIGHT = 357

TILESIZE = 16
Map_IMG = '../Holder/Adjusted_Map_scale.png'

```

---

<div class="post-metadata">

**Author:** ![eryksun](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/eryksun/32/697_2.png) [@eryksun](https://discuss.python.org/u/eryksun)\
**Post date:** [January 2, 2023, 5:04am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/8 "2023-01-02T05:04:09Z")

</div>

> [@Dinzai](#):
>
> ```auto
> tmx_data = load_pygame("G:/Tiled/Game Python Files/Adjusted TileSet for MapEditor/Maps/Kanto Tiled Map Files")
> 
> ```

According to the [documentation](https://pytmx.readthedocs.io/en/latest/contents.html#pytmx.util_pygame.load_pygame), the argument should be the path of a TMX file, but it looks like you passed the path of a directory.

On Windows, attempting to open a directory as if it’s a regular file fails with `ERROR_ACCESS_DENIED`, which the C runtime translates to `EACCES` (13). In turn, the Python runtime raises `PermissionError`. In this case, the permission error has nothing to do with file security.

---

<div class="post-metadata">

**Author:** ![steven.daprano](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/steven.daprano/32/1083_2.png) [@steven.daprano](https://discuss.python.org/u/steven.daprano)\
**Post date:** [January 2, 2023, 6:09am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/9 "2023-01-02T06:09:42Z")

</div>

Hi Brett, and welcome. Happy new year!

It looks like Eryk Sun has probably identified the cause of your error. Please let us know if that fixes it.

But for the future, please don’t dump dozens or hundreds of lines of code into our laps. We’re volunteers, not paid to analyse your code, and the more code you dump on us, the fewer volunteers you will get.

The best way to ask for help is to spend some time to produce a [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example).

In your case, the minimal example would probably be something like:

```python
from pytmx.util_pygame import load_pygame
tmx_data = load_pygame("G:/Tiled/Game Python Files/Adjusted TileSet for MapEditor/Maps/Kanto Tiled Map Files")

```

although as a beginner, you would be doing pretty well to get it down that far! But every bit helps: every additional 10 lines of code probably halves the number of people willing to read it. (Yes, we’re lazy. If you paid us, you could fire us, but you don’t so you can’t 🙂

You can read more advice [here](http://www.sscce.org).

Ideally, you should be aiming for maybe ten or twenty lines of code that we can run that demonstrates the problem.

@eryksun do you think the error message for EACCES (13) / PermissionError could be improved? Is it worth raising a ticket for it?

---

<div class="post-metadata">

**Author:** ![Rosuav](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rosuav/32/3429_2.png) [@Rosuav](https://discuss.python.org/u/Rosuav)\
**Post date:** [January 2, 2023, 6:15am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/10 "2023-01-02T06:15:05Z")

</div>

> [@steven.daprano](#):
>
> @eryksun do you think the error message for EACCES (13) / PermissionError could be improved? Is it worth raising a ticket for it?

On Linux, `open(".")` raises IsADirectoryError, which is a subclass of OSError. Can someone with a Windows computer quickly check what happens there? If it is indeed PermissionError, then this is a Python-wide thing, but if it’s IsADirectoryError, this is actually a pygame issue and not a Python one.

---

<div class="post-metadata">

**Author:** ![eryksun](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/eryksun/32/697_2.png) [@eryksun](https://discuss.python.org/u/eryksun)\
**Post date:** [January 2, 2023, 7:43am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/11 "2023-01-02T07:43:31Z")

</div>

> [@Rosuav](#):
>
> > [@steven.daprano](#):
> >
> > @eryksun do you think the error message for EACCES (13) / PermissionError could be improved? Is it worth raising a ticket for it?
> 
> On Linux, `open(".")` raises IsADirectoryError, which is a subclass of OSError. Can someone with a Windows computer quickly check what happens there? If it is indeed PermissionError, then this is a Python-wide thing, but if it’s IsADirectoryError, this is actually a pygame issue and not a Python one.

```auto
>>> open('.')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
PermissionError: [Errno 13] Permission denied: '.'

```

Python `open()` calls WinAPI `CreateFileW()` without using the flag that enables opening directories (i.e. `FILE_FLAG_BACKUP_SEMANTICS`). In turn, `CreateFileW()` calls the NT system function [`NtCreateFile()`](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-ntcreatefile) with the option `FILE_NON_DIRECTORY_FILE`, which requires opening a regular file. In this case, if the opened path is a directory, the system call fails with the status code `STATUS_FILE_IS_A_DIRECTORY`. The `CreateFileW()` call maps this status code to the Windows error code `ERROR_ACCESS_DENIED`, which the C runtime maps to `EACCES`, and Python raises `PermissionError`.

One step that we could easily take in `io.FileIO` is to use the `_doserrno` value to get the underlying Windows error code when C `_wopen()` fails. This is sometimes helpful because commonly several Windows error codes are mapped to the same C `errno` value. (Unfortunately, it wouldn’t help in this case.) Note that, unlike `open()`, most of the functions in the `os` module report a `winerror` value in the exception because the Windows API is consumed directly. I don’t know why Python has never used the CRT’s `_doserrno` value. It isn’t standard C, but it dates back to a least the 1990s in the earliest versions of the CRT on NT systems, and it was always documented.

It’s also possible to get the original NT status code, but we’re on much more dubious footing in this case. The function to get the last NT status, `RtlGetLastNtStatus()`, is undocumented (but stable back to the 1990s). Moreover, the Windows API is free to set a last error that’s unrelated to the last NT status code. There’s no software contract regarding how the Windows API consumes the NT API. That said, it would help in this case, for whatever it’s worth.

For example:

```auto
import os
import errno
import ctypes

RtlGetLastNtStatus = ctypes.WinDLL('ntdll').RtlGetLastNtStatus
STATUS_FILE_IS_A_DIRECTORY = ctypes.c_long(0xC000_00BA).value
ERROR_ACCESS_DENIED = 5

# BUGBUG: In debug builds, this must use the debug CRT, "ucrtbased".
_doserrno = ctypes.CDLL('ucrtbase').__doserrno
_doserrno.restype = ctypes.POINTER(ctypes.c_ulong)

def opener(name, flags):
    try:
        return os.open(name, flags)
    except OSError as e:
        ntstatus = RtlGetLastNtStatus()
        winerror = _doserrno()[0]
        if (e.errno == errno.EACCES and winerror == ERROR_ACCESS_DENIED and
              ntstatus == STATUS_FILE_IS_A_DIRECTORY):
            e = IsADirectoryError(errno.EISDIR, os.strerror(errno.EISDIR),
                    e.filename, winerror)
            raise e from None
        raise

```

```auto
>>> open('.', opener=opener)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 24, in opener
IsADirectoryError: [WinError 5] Is a directory: '.'

```

---

<div class="post-metadata">

**Author:** ![tjreedy](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/tjreedy/32/137_2.png) [@tjreedy](https://discuss.python.org/u/tjreedy)\
**Post date:** [January 2, 2023, 7:45am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/12 "2023-01-02T07:45:11Z")

</div>

`PermissionError: [Errno 13] Permission denied: '.'`  
I have gotten this and been mystified before. If I get it in the future, I will look at the path more carefully.

---

<div class="post-metadata">

**Author:** ![Rosuav](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/rosuav/32/3429_2.png) [@Rosuav](https://discuss.python.org/u/Rosuav)\
**Post date:** [January 2, 2023, 7:49am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/13 "2023-01-02T07:49:26Z")

</div>

> [@eryksun](#):
>
> Python `open()` calls WinAPI `CreateFileW()` without using the flag that enables opening directories (i.e. `FILE_FLAG_BACKUP_SEMANTICS`). In turn, `CreateFileW()` calls the NT system function [`NtCreateFile()`](https://learn.microsoft.com/en-us/windows-hardware/drivers/ddi/ntifs/nf-ntifs-ntcreatefile) with the option `FILE_NON_DIRECTORY_FILE`, which requires opening a regular file. In this case, if the opened path is a directory, the system call fails with the status code `STATUS_FILE_IS_A_DIRECTORY`. The `CreateFileW()` call maps this status code to the Windows error code `ERROR_ACCESS_DENIED`, which the C runtime maps to `EACCES`, and Python raises `PermissionError`.

Good to get that confirmed. Ugh, it’s a mess.

Worst case, would it be possible to do it as part of the exception-printed-to-console checks? Same place as going “hey, that’s a NameError, but maybe you meant this”, so it’s only costly when it actually ends the process. It’s not going to be perfect, as it would involve statting the file after the exception has gone through, but for common cases it would be easier to understand.

---

<div class="post-metadata">

**Author:** ![eryksun](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/eryksun/32/697_2.png) [@eryksun](https://discuss.python.org/u/eryksun)\
**Post date:** [January 2, 2023, 8:04am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/14 "2023-01-02T08:04:35Z")

</div>

Actually, it occurs to me that there’s a simpler way to handle this. We can use the CRT’s undocumented flag\[1\] `_O_OBTAIN_DIR` (0x2000) to get backup semantics in the `_wopen()` call. Because POSIX `open()` allows opening a directory, `io.FileIO` already has to manually raise `IsADirectoryError` on POSIX systems, so we get that for ‘free’. For example:

```auto
import os

_O_OBTAIN_DIR = 0x2000

def opener(name, flags):
    return os.open(name, flags | _O_OBTAIN_DIR)

```

```auto
>>> open('.', opener=opener)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
IsADirectoryError: [Errno 21] Is a directory: '.'

```

* * *

1. Microsoft publishes the source code of the CRT, and the flag is in the public headers, so we’re not talking about an internal, private feature that we’ve reverse engineered.

---

<div class="post-metadata">

**Author:** ![petersuter](https://avatars.discourse-cdn.com/v4/letter/p/13edae/32.png) [@petersuter](https://discuss.python.org/u/petersuter)\
**Post date:** [January 2, 2023, 12:06pm UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/15 "2023-01-02T12:06:37Z")

</div>

Improving this error message would help [a lot of people](https://stackoverflow.com/questions/36434764/permissionerror-errno-13-permission-denied). It’s a common error and it’s always quite confusing / misleading.

---

<div class="post-metadata">

**Author:** ![Dinzai](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/dinzai/32/10444_2.png) [@Dinzai](https://discuss.python.org/u/Dinzai)\
**Post date:** [January 2, 2023, 3:06pm UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/16 "2023-01-02T15:06:23Z")

</div>

````
```python
# FileNotFoundError: No such file or directory: 'G:/Tiled/Game Python Files/Adjusted 
#TileSet for MapEditor/Maps/Kanto Tiled Map Files\../Kanto Tiled Map 
#Files\../Map/Adjusted_Map_scale.png'.
#For some reason it can't find a png but i am specifying a .tmx
tmx_data = load_pygame("G:/Tiled/Game Python Files/Adjusted TileSet for 
MapEditor/Maps/Kanto Tiled Map Files/Kanto_alpha.tmx")
```

````

---

<div class="post-metadata">

**Author:** ![Dinzai](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/dinzai/32/10444_2.png) [@Dinzai](https://discuss.python.org/u/Dinzai)\
**Post date:** [January 2, 2023, 3:08pm UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/17 "2023-01-02T15:08:36Z")

</div>

I was really excited that the error had a simple solution, though adding the .tmx to the path gives me a similar error except it is looking for a .png related to the project ( a png that made a .tsx tile set)

---

<div class="post-metadata">

**Author:** ![Dinzai](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/dinzai/32/10444_2.png) [@Dinzai](https://discuss.python.org/u/Dinzai)\
**Post date:** [January 2, 2023, 4:28pm UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/18 "2023-01-02T16:28:07Z")

</div>

it would help me to understand the problem if i knew what was wrong  
in this directory  
‘G:/Tiled/Game Python Files/Adjusted TileSet for MapEditor/Maps/Kanto Tiled Map Files../Kanto Tiled Map Files../Adjusted TileSet for MapEditor/Towns or Cities/Pallet\_town.png’  
Why does it say —\> /Kanto Tiled Map Files../Kanto Tiled Map Files../  
More specifically, what does the ../ mean and why is it using the folder twice?  
i’ve even tried stacking the folder to try to appease it with only getting more and more complex variations of the error

---

<div class="post-metadata">

**Author:** ![steven.daprano](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/steven.daprano/32/1083_2.png) [@steven.daprano](https://discuss.python.org/u/steven.daprano)\
**Post date:** [January 3, 2023, 2:45am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/19 "2023-01-03T02:45:34Z")

</div>

The double dot means to move up to the parent directory.

When Python goes to open the file, it has to walk through the list of folders:

```
'G:/Tiled/Game Python Files/Adjusted TileSet for MapEditor/Maps/Kanto Tiled Map Files\../Kanto Tiled Map Files\../Adjusted TileSet for MapEditor/Towns or Cities/Pallet_town.png'

```

so starting at G drive, it goes to `Tiled` then `Game Python Files` and so on, up to `Maps` then `Kanto Tiled Map Files` **and then** it hits the double dot `..` which moves back up to the parent, namely `Maps`, and from there it tries to move to `Kanto Tiled Map Files`, then it his another double dot and moves back to `Maps`, and so on.

It’s a mess. Why is it written that way? I don’t know, you wrote it.

You should clean up the path, make sure it is correct, and that nothing is misspelled, and that the Pallet\_town.png file actually exists where you are telling Python to look.

Also, you should only use forward slashes `/` for path separators, not the backslash, which _can_ work in Windows but can also cause trouble. It’s often easier to just avoid backslashes by changing them into forward slashes.

```
# Sometimes this is problematic:
G:\Tiled\

# This is usually better:
G:/Tiled/

```

> [@](#):
>
> i’ve even tried stacking the folder to try to appease it with only getting more and more complex variations of the error

What does “stacking the folder” mean?

Making random changes to pathnames is unlikely to help. That’s like trying to fix a broken down car by randomly hitting parts of the engine with a big sledgehammer.

---

<div class="post-metadata">

**Author:** ![eryksun](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/eryksun/32/697_2.png) [@eryksun](https://discuss.python.org/u/eryksun)\
**Post date:** [January 3, 2023, 5:10am UTC](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360/20 "2023-01-03T05:10:37Z")

</div>

> [@steven.daprano](#):
>
> It’s a mess. Why is it written that way? I don’t know, you wrote it.

Apparently Brett called `load_pygame("G:/Tiled/Game Python Files/Adjusted TileSet for MapEditor/Maps/Kanto Tiled Map Files/Kanto_alpha.tmx")`. Then, for whatever reason, the pytmx library removed the base filename “Kanto\_alpha.tmx” and tried to open `"G:/Tiled/Game Python Files/Adjusted TileSet for MapEditor/Maps/Kanto Tiled Map Files\\../Map/Adjusted_Map_scale.png"`, which wasn’t found.

[Next page](https://discuss.python.org/t/permissionerror-errno-13-permission-denied-python-2023/22360.md?page=2)
