Python

Default to User Installation Because Normal Site Packages Are Not Writeable


“When trying to install Python packages, you may sometime encounter “default to user installation because normal site-packages are not writeable” error. In this attempt, we will explain why this error occurs and how we can resolve it.”

Let’s get started.

Causes of This Error

Various reasons may cause this error to occur. These include:

  1. Multiple Python versions
  2. Permission Error

The following are some of the techniques you can use to resolve this error.

Fix #1 – Specify the Explicit Version

Sometimes, you may have multiple versions of the Python interpreter installed. For example, if you have both Python version 3.9 and 3.10 installed, running the pip3 install <package_name> command will result in an error.

This is because Python will attempt to install the package in the default Python directory. This directory is directly managed by Python and will return an error.

Therefore, if you have multiple versions of the interpreter installed, you need to specify it in the command explicitly.

For example, to install a package with the Python3.10 pip, run the command:

$ python3.10 -m pip install <package_name>

The above should invoke the module associated with the specific Python interpreter and use it to install the specified package.

Fix #2 – Run Pip With the Sufficient Permissions

On a multi-user system such as Linux, you may face the “default to user installation because normal site-packages are not writeable” error due to insufficient permissions.

Therefore, ensure to run pip with sufficient permissions to access the installation directory.

Similarly, ensure that the installed Python interpreter is installed for users with sufficient permissions.

Fix #3 – Update Your Python Version

Another attempt you can take to resolve this is to update your Python version. This may force the system to reconfigure the interpreter and fix any issues.

Fix #4 – Re-Install Python

If neither of the above methods works, you can uninstall your current Python interpreter and re-install Python.

Conclusion

That’s it for this one. Although the reasons may vary, one major cause of the “defaulting to user installation because normal site-packages are not writeable” error is conflicting Python versions. We hope this article helped you resolve the issue.

Thanks for reading!!

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list