# Problem in python

**URL:** <https://discuss.python.org/t/problem-in-python/46981>\
**Category:** Python Help\
**Tags:** help\
**Created:** [February 27, 2024, 4:28am UTC](https://discuss.python.org/t/problem-in-python/46981 "2024-02-27T04:28:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Skarty](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@Skarty](https://discuss.python.org/u/Skarty)\
**Post date:** [February 27, 2024, 4:28am UTC](https://discuss.python.org/t/problem-in-python/46981/1 "2024-02-27T04:28:59Z")

</div>

when I run this it gives me traceback (most recent call last):

```python
file "C:\new folder\url.py", line 90, in <module> main()
file "C:\new folder\url.py", line 71, in main create_folders()
file "C:\new folder\url.py", line 66, in create_folders os.makedirs(folder)
file "<frozen os>", line 225, in makedirs
PermissionError: [WinError 5] access denied "valid_url"

```

 ![Capture d’écran 2024-02-27 052731](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/0/d/0db22c786ed6c484297bb0bbc26513ba0f93355f.png)

Im french 😅

---

<div class="post-metadata">

**Author:** ![CAM-Gerlach](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cam-gerlach/32/3688_2.png) [@CAM-Gerlach](https://discuss.python.org/u/CAM-Gerlach)\
**Post date:** [February 27, 2024, 4:59am UTC](https://discuss.python.org/t/problem-in-python/46981/3 "2024-02-27T04:59:46Z")

</div>

Welcome to the Python Discourse! As a reminder, please [don’t post screenshots of your code](https://meta.stackoverflow.com/a/285557). Instead, post code and complete tracebacks _as code_, inside a code block like this:

````markdown
```
YOUR CODE HERE
```

````

You can copy-paste the above, or use the `</>` button in the editing toolbar. I fixed the formatting around your traceback in your post above, so you can also use that as an example.

* * *

Anyway, as the error message states:

> [@Skarty](#):
>
> ```python
> PermissionError: [WinError 5] access denied "valid_url"
> 
> ```

For one reason or another, the user account you’re running your script under does not have permission to create a new folder in the indicated directory. This is entirely controlled by your operating system rather than Python, so you’ll need to check your operating system permissions on that. Instead of running it in the root of your drive, you might want to run it in your user home directory instead (`C:/Users/<username>` on Windows), where you should have full permissions. Or, if you do create a directory somewhere else, check the permissions on the parent directory to make sure your user has full read write permissions on anything created therein.

* * *

On a side note, you can greatly simplify your code by taking advantage of options already built in to the functions you’re using. For example, you have this code:

![image](https://us1.discourse-cdn.com/flex002/uploads/python1/original/3X/f/9/f994c852a3d05a43d7b405bff5dcd57742357aee.png)

You can use the `exist_ok` and `mode` arguments to `os.makedirs` to replace all of the above manual code with just:

```python
def create_folders(folders=('valid_urls', 'invalid_urls')):
    for folder in folders:
        os.makedirs(folder, mode=0o777, exist_ok=True)

```

You might want to consider use of the `pathlib` standard library module instead of the older `os.path`, as many operations are simpler, cleaner and easier to use.

---

<div class="post-metadata">

**Author:** ![CAM-Gerlach](https://sea2.discourse-cdn.com/flex002/user_avatar/discuss.python.org/cam-gerlach/32/3688_2.png) [@CAM-Gerlach](https://discuss.python.org/u/CAM-Gerlach)\
**Post date:** [March 5, 2024, 1:43am UTC](https://discuss.python.org/t/problem-in-python/46981/4 "2024-03-05T01:43:44Z")

</div>

3 posts on a completely different issue were split to a new topic: [[Split] TypeError: Updater. **init** () got an unexpected keyword argument ‘use\_context’](https://discuss.python.org/t/split-typeerror-updater-init-got-an-unexpected-keyword-argument-use-context/47623)

As a sidenote, this is one good reason why you should avoid giving your post a generic title like “Problem in Python” (that could apply to nearly every one of the posts in #Python Help 🙂 ) and give it an actual useful, helpful title describing the problem instead. (I used to do that for users at least on the most egregious examples, but I’ve refrained from doing so at all ever since it upset another user here.)
