Macos – Fixing site-packages permission for pip/python

macosmacos catalinapermissionspippython

I have a new Macbook – a user installed it, and then I installed a new user (mine), granted admin privileges and deleted the old one. I am on OS Catalina.

Since the installation I've been having several permission problems. VSCode can't find Jupyter Notebook, pip installs packages at ~/Library/Python/3.7/site-packages.

When I do which python3 I get usr/bin/python3. When I do pip3 install <package> I get: Defaulting to user installation because normal site-packages is not writeable And then it says it has already been installed, even though I can't access it when I do import .

It's seems clear that this is a permission problem, pip can't install to the "base" python, and them python can't find what I've installed into ~/Library/Python/3.7/site-packages.

I've tried reinstalling the OS, but since I haven't done a clean install, it didn't change anything. What am I missing? How exactly can I fix permissions? Where do I want packages to be installed (venv sure, but some packages I want global (like jupyter).

Thanks

Best Answer

There's no reason to start over from what I can see here. This is a basic python and unix permission issue, forget that it's a mac. Given that you have admin permissions, and considering where Python is installed as well as where the packages are, I don't see a reason to do a clean install. If there were for some crazy reason (I don't think there is,) a python folder with the ownership belonging to the old user, you should be able to take ownership considering the folder isn't in their home directory, and considering the fact that you have admin/sudo abilities.

I'd start by running an "ls -lah" against ~/Library/Python/3.7/site-packages and see if there are different permissions set for your new package folder. If there are, edit them so that they're more permissive, or so that they belong to the right group.

Related Question