pip install fails with “Permission denied” on Python 3+

Overview

Python’s integrated package manager, pip, fails to install packages when Python 3.0 and above is used raising a PermissionError. Below is an abbreviated sample output:

[myadmin@sol]$ pip install django
Downloading/unpacking django
Installing collected packages: django
Cleaning up...
Exception:
Traceback (most recent call last):
 File "/.socket/python/python3.4/site-packages/pip/wheel.py", line 205, in clobber
 os.makedirs(destdir)
 File "/.socket/python/python3.4/os.py", line 237, in makedirs
 mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/.socket/python/python3.4/site-packages/django'

Cause

pip bundled with Python 3.0 and above include support for wheel, a successor to an earlier package format, egg. wheel is called after package installation without exposing custom configuration. wheel, unaware that libraries are installed to version-specific directories, tries to install in the system Python location unsuccessfully.

Solution

Disable wheel processing with --no-use-wheel as an argument to pip install or add the following configuration within ~/.pip/pip.conf, inside your home directory:

[global]
use-wheel = no

Most accounts should have wheel disabled by default.

See also

Leave a Reply