- Defaulting to user installation because normal site-packages is not writeable
- Defaulting to user installation because normal site-packages is not writeable
- Error/Exception
- Solution 1
- Python 3
- Python 2
- Solution 2
- Run Command
- Create a virtual environment
- Check the permissions
- Solution 3
- Cause
- Best practices for preventing Defaulting to user installation because normal site-packages is not writeable
- Overview: Defaulting to user installation because normal site-packages is not writeable
- Example: Defaulting to user installation because normal site-packages is not writeable
- Conclusion
- Fixing site-packages permission for pip/python
- Related videos on Youtube
- lowercase00
- Comments
Defaulting to user installation because normal site-packages is not writeable
When installing packages in Python, you may come across the message “Defaulting to user installation because normal site-packages is not writeable“. This message typically means that the Python interpreter does not have the necessary permissions to write to the system’s site-packages directory. As a result, Python is defaulting to installing the package in the user’s local directory, which should be writeable. While this message can be confusing at first, it is actually a helpful reminder that Python is installing the package in a slightly different location than usual, so you should be aware of where the package is being installed.
Defaulting to user installation because normal site-packages is not writeable
Error/Exception
Defaulting to user installation because normal site-packages is not writeable
Collecting pandas Downloading pandas-1.3.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.5 MB) |████████████████████████████████| 10.5 MB 5.5 MB/s Defaulting to user installation because normal site-packages is not writeable
Solution 1
Python 3
python3 -m pip install [package_name]
Python 2
python -m pip install [package_name]
Solution 2
If you see the message “Defaulting to user installation because normal site-packages is not writeable” when installing Python packages, it means that your Python interpreter does not have the necessary permissions to write to the system’s site-packages directory. In this case, Python will install the package in the user’s local directory, which should be writeable. To avoid this message and install packages directly to the system’s site-packages directory, you can try running the installation command with administrator privileges or use a virtual environment to install packages locally without requiring system-level permissions. Additionally, you can modify the Python installation to ensure that the system’s site-packages directory is writeable by the user or group that you are using to run Python.
Here are some steps you can take to resolve the “Defaulting to user installation because normal site-packages is not writeable” message when installing Python packages
Run Command
Try running the installation command with administrator privileges by using the “sudo” command on Linux or macOS, or by right-clicking and selecting “Run as administrator” on Windows.
Create a virtual environment
Alternatively, you can create a virtual environment to install packages locally without requiring system-level permissions. To create a virtual environment, you can use the “venv” module included with Python, or a third-party tool like “virtualenv”.
Check the permissions
If you prefer to modify the Python installation itself, you can check the permissions of the site-packages directory and ensure that the user or group you are using to run Python has write access to that directory. However, modifying the Python installation itself is not recommended unless you have a good understanding of the potential risks and consequences.
Solution 3
- pip3 install –upgrade pip
- python3 -m pip install –upgrade pip
- python3.7 -m pip install –upgrade pip
Cause
The main cause of the “Defaulting to user installation because normal site-packages is not writeable” message is that the Python interpreter does not have the necessary permissions to write to the system’s site-packages directory. The site-packages directory is a directory used by Python to store globally installed packages, and it is typically located in the system’s Python installation directory.
If the user or group that is running Python does not have write access to the site-packages directory, Python will be unable to install packages globally and will default to installing them in the user’s local directory, which should be writeable. This can lead to the “Defaulting to user installation because normal site-packages is not writeable” message being displayed during the installation process.
Other factors that can contribute to this issue include incorrect file permissions or ownership on the system’s Python installation directory, running Python as a non-root user, or using a non-standard Python installation directory. By ensuring that the user or group running Python has the necessary permissions to write to the site-packages directory, you can help prevent this issue from occurring.
Best practices for preventing Defaulting to user installation because normal site-packages is not writeable
Here are some best practices you can follow to prevent the “Defaulting to user installation because normal site-packages is not writeable” message when installing Python packages:
- Use a virtual environment: Creating a virtual environment using tools like venv or virtualenv allows you to install packages locally without requiring system-level permissions. This can help prevent issues related to write permissions and ensure that your Python environment is isolated from other Python installations on the system.
- Use pip install –user: If you want to install packages globally, you can use the pip install –user command to install packages in the user’s local directory, which should be writeable. This can help prevent issues related to write permissions and allow you to install packages globally without requiring administrator or root-level permissions.
- Check permissions on site-packages directory: If you need to install packages globally and are encountering write permission issues, you can check the permissions on the system’s site-packages directory and ensure that the user or group you are using to run Python has write access to that directory. However, modifying the Python installation itself is not recommended unless you have a good understanding of the potential risks and consequences.
- Use a package manager: Using a package manager like conda or apt can help ensure that your Python packages are installed in a consistent and controlled manner, without requiring system-level permissions. Package managers can also help manage dependencies and ensure that your Python environment is isolated from other installations on the system.
Overview: Defaulting to user installation because normal site-packages is not writeable
Exception | Defaulting to user installation because normal site-packages is not writeable |
Programming Language | Python |
Solution | Resolved |
Error/Exception Type | During the installation process |
Defaulting to user installation because normal site-packages is not writeable solution
Example: Defaulting to user installation because normal site-packages is not writeable
Here is an example of the “Defaulting to user installation because normal site-packages is not writeable” message that you might see when installing Python packages
Collecting pandas Downloading pandas-1.3.3-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (10.5 MB) |████████████████████████████████| 10.5 MB 5.5 MB/s Defaulting to user installation because normal site-packages is not writeable
In this example, Python is attempting to install the “pandas” package, but encounters the message “Defaulting to user installation because normal site-packages is not writeable”. This message is displayed because the Python interpreter does not have the necessary permissions to write to the system’s site-packages directory, so Python is defaulting to installing the package in the user’s local directory.
Conclusion
The “Defaulting to user installation because normal site-packages is not writeable” message is an informational message that can occur when installing Python packages. It indicates that the Python interpreter does not have the necessary permissions to write to the system’s site-packages directory, and Python is therefore defaulting to installing packages in the user’s local directory. To avoid encountering this message, you can try running the installation command with administrator privileges or create a virtual environment to install packages locally without requiring system-level permissions. Additionally, you can modify the Python installation to ensure that the system’s site-packages directory is writeable by the user or group that you are using to run Python. By taking these steps, you should be able to install Python packages without encountering any issues related to write permissions.
Fixing site-packages permission for pip/python
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 videos on Youtube
lowercase00
Updated on September 18, 2022
Comments
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
I’d be tempted to start over — the original install will belong to the AppleID of that first user. Eventually you’ll hit some point their ID is needed & you won’t know it.