IDLE PermissionError Mac

Device: MacBook Pro M1 16GBRAM
OS: Monetary 12.3.1
Issue Program: Python IDLE Shell

Hi all,

This is my first post so thanks for reading!

I am a real beginner at coding, and have decided to learn Python. I have bought myself the Beginner’s Step By Step Coding Course book to help with my journey and am completing basic exercises from it.

I am attempting to create a ‘Project Planner’ (Gantt chart) using IDLE.

After writing the necessary code I keep getting the same error:

ead_tasks(“project.csv”)
Traceback (most recent call last):
File “<pyshell#0>”, line 1, in
read_tasks(“project.csv”)
File “/Users/MrControla/Documents/Projects/Python/Project Planner/planner.py”, line 4, in read_tasks
for row in csv.reader(open(project)):
PermissionError: [Errno 1] Operation not permitted: ‘project.csv’

I have googled the “PermissionError” and have found forums saying I need to go into Security & Privacy > Full Disk Access > then give full disk access permission to IDLE and Terminal. Having done that, I still have the same PermissionError.

Further googling suggest making changes in safe mode to the operating system, or using a docker container to create the code in. All of which sounds far too complicated for a simple program I am trying to create.

I have also found forums saying that M1 MacBooks have restricted permissions that are set by Apple and many other people have come across problems with python.

I have reached out to Apple and opened a ticket with them, they have checked my user rights and confirm I’m an administrator who should have necessary permissions. Apple has suggested I reach out to the Python team to see if it’s a known problem there may be a solution for.

Apple is going to continue the support if not and delve further into my permissions, but wanted to eliminate this possibility first.

Funnily, I had a similar problem when trying to use Arduino on my MacBook Pro M1and I couldn’t get it to download the driver. I then reverted to using my MacBook Air 2012 and the program worked first time recognising the device I was using. This makes me think there is an issue with MacBook Pro security features preventing me from accomplishing my coding tasks.

Apologies for the long post, I figure more information is better to assist me, so if you made it this far thank you. If you would like to see my code I have written to help trouble shoot this task please ask, as you never know, the problem may just be between my keyboard and my chair!

Thanks all, I look forward to your reply.

Regards

MrControla

Hi and welcome.

It looks to me that read_tasks() is a custom function, within the script and as such we can only guess at what it’s trying to do.

Also, please post your code within backtics, like this:

```python
your code goes here
```

Hi Rob!

Thank you for your reply!

I hope you can forgive me not writing my code within brackets on my first post :slight_smile:

Just wanted to give a quick update, I have gotten frustrated so I have just tried this script on my MacBook Air Mid 2012 edition running Catelina v10.15.7 and guess what… it worked!

I have my MacBook Pro and MacBook Air next to each other right now, and it works on the air but not the pro, using the same script as its saved on iCloud.

So this would suggest to me its an issue with permissions on my MacBook Pro M1.

Is that a reasonable conclusion? Any suggestions what my next steps here would be apart from going back to Apple with my findings?

Many thanks

MrControla

No worries. It’s ‘backtics’ for the code format, not ‘brackets’, btw. It just makes reading code way less hassle, if it’s correctly formatted; the easier your posts are to read, the better :sunglasses:

As I’m not a Mac user, I can only guess at the issue, but the first thing I’d check on is to make sure that IDLE is being run by/with the same user account association as the file that it’s trying to read.

e.g: if IDLE is being run with an account called ‘rob’, but the .cvs file belongs to ‘root’ (as an example) then IDLE will not be able to read that file.

I hope that this is for some help.

As sidebar: this does not sound like a good thing to do as it seems to me, on the face of it, that you may very well introduce security issues.

Ah backtics ok got ya! Thanks

So I’ve just got off an hour long debugging call with Apple and it always comes back to the old saying, “have you tried turning it off and on again”…!

But strangely in this case, it was my Apple ID that I needed to sign out of then sign back into.

We could see it was working on my MacBook Air using the iCloud files from my Apple ID, and we created a test ‘log in’ account on my MacBook Pro and were able to successfully run the script from from iCloud using my Apple ID as well as a backup saved onto an external hard drive.

Back in my main user account we could run it from the external hard drive successfully, so we decided to give signing out and back into my Apple ID a try as it was working on the other login and my MacBook Air. And voila…

The coding exercise was only supposed to take 1.5 hours and I’ve probably spent around 6 hours trying to figure out why it wasn’t working. Haha, always then way!

Time for a break I think and I’ll come back to this over the weekend.

Thank you for your help and suggestions, I guess the solution was similar to what you said about the user account association but it wasn’t obvious until we realised it worked on everything but my current Apple ID logon.

Cheers Rob.

P.S not sure how to close this thread? or if I need to, please do let me know if so to keep the admins happy. :slight_smile:

ok thanks may revert and test it still works. :+1:

Pleased that you’re good to go.

You may be able to add a ‘Solved’ tag to this thread: I’m new to this Forum myself, so I’ve not tried that yet.

Have a good day, happy coding (Python is so nice to code with) and be safe.

Peace.

1 Like

What happens if you run this code alone?

with open("project.csv", "r"):
    pass

Do you still get the same error?

Can you double-check and triple-check that you have permissions to read that file?

Try this:

with open("myjunkfile.txt", "w") as f:
    f.write("junk")

Do you get an error writing to that file? If not, then go to the second step:

with open("myjunkfile.txt", "r") as f:
    print(f.read())

Do you get an error?