Ubuntu: Pip installing always results in error [duplicate]



Question:

This question already has an answer here:

I wanted to install cx_freeze or pyInstaller for running my python game also on cross platforms without the need of having installed python3 and pygame. But the command sudo pip install cx_freeze (or pyInstaller) as indicated on their makers webpages doesn't work for me. The error that always occurs then is the following:

The directory '/home/h3friend/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag. The directory '/home/h3friend/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.

Has anyone an idea what I need to do in order to fix this?

Thanks in advance!


Solution:1

Pip needs to use files in your home directory, owned by the current user, to run, and sudo to run globally, which changes your user to the root user. Sudo's -H flag (mentioned in the error message) will make sudo behave as if you still own your home directory.

TL;DR:

Do sudo -H pip install cx_freeze.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »