When using Python you mostly rely on pip to install necessary libraries. Recently I ran the following command on my Mac:
pip install lxml
The result was the following output:
error: could not create '/Library/Python/2.7/site-packages/lxml': Permission denied
Obviously, writing to the folder /Library/ is not possible for a normal user account. There are several possible options to overcome this problem.
- You can use the command sudo pip install lxml to install the package
- You can use the command STATIC_DEPS=true sudo pip install lxml to install the package. This will download libxml2 and libxslt and build the source distribution afterwards.
- You use virtualenv to install the package only locally in your current project directory. See here for a good tutorial of virtualenv.
From my perspective option 3 is the cleanest way to install and manage lxml.