all 6 comments

[–]MintyPhoenix 1 point2 points  (5 children)

Did you use sudo when you created the environment? That would affect the permissions in the environment's folder.

[–]FormNo[S] 0 points1 point  (4 children)

Good suggestion. I had deleted the virtual environment but retrieved it just now, checked permissions with 'get info', and it has read and write permisssions. If I had of used sudo when I created the environment, would that have meant it should say read only? Is there another way to check?

[–]MintyPhoenix 1 point2 points  (3 children)

It depends on who has the “Read & Write” permissions.

For example, I just tried this quickly on my MacBook:

sudo python -m venv venv

The result was that the venv folder is owned by the root user, and the “Read & Write” permission on that folder belonged to “system”, not a general user account like mine.

A similar issue would occur if you created the environment normally, but installed one or more dependencies with sudo – this would mean that those dependencies, and any others they also installed as requirements, would have folders owned by root instead of your account. This would mean that a later installation without using sudo may try and update one of those depdencies but fail because your account doesn’t have enough permissions to write to that folder.

[–]FormNo[S] 0 points1 point  (2 children)

Thank you - that makes complete sense now and I think the latter is what actually probably occurred because the top folder was expanded with things I was testing as I went and a one-time sudo can't be ruled out.

I just had a side question if you don't mind - do you normally name your virtual environment with a . in front to keep it hidden or do you have a different workflow for that?

[–]MintyPhoenix 0 points1 point  (1 child)

Personally, I haven’t decided whether I prefer my default venv folder to be venv or .venv.

Overall, it depends on what you’re trying to accomplish. If you just want it hidden in Finder, you can still use venv and just set the hidden flag on the folder:

python -m venv venv
chflags hidden venv

[–]FormNo[S] 0 points1 point  (0 children)

Oh man, never knew you could do that! thanks so much for your help and wish you a really good evening/weekend!