Unable to install gittle library without root priv

2019-08-10 09:55发布

问题:

I followed this link to install Gittle library. But when I run a command

$ pip install gittle

I get an error:

Command /usr/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_victor /gittle/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-aoyPEt-record/install-record.txt --single-version-externally- managed --compile failed with error code 1 in /tmp/pip_build_victor/gittle Storing debug log for failure in /home/victor/.pip/pip.log

My Python version is 2.7.6.

回答1:

You Need Root Privileges

Since you are installing sistem-wide libraries, these usually will be placed in directories which need root privileges for writing in them (for example anything under /usr/lib). Hence you need to either run the command as root:

# pip install gittle

Or you can use sudo:

$ sudo pip install gittle

What About Virtual Environments?

The more efficient/pythonic way to go about this would be using virtual environments. This is especially true if you are installing project-specific libraries, which will most probably not be required by other projects. Another classical application of virtual environments is when you are working on a machine on which you don't have root privileges, say at university for example.

Once you set up a virtual environment, if you place it in a directory on which you have writing rights, you can run:

$ pip install gittle

to install gittle in this case.