Search code examples
pythondjangopipproduction

Permissions denied on production server when using pip install


I am trying to install a package to my Django application on the production server, and am getting a permission denied error. Below is the traceback. I have installed other packages with pip install, and it hasn't given me any issues, so I am not entirely sure why I am getting this issue.

[humanlink@web526 ~]$ pip install cryptography
Collecting cryptography
  Using cached cryptography-1.4.tar.gz
Requirement already satisfied (use --upgrade to upgrade): idna>=2.0 in ./lib/python2.7 (from cryptography)
Requirement already satisfied (use --upgrade to upgrade): pyasn1>=0.1.8 in ./lib/python2.7 (from cryptography)
Requirement already satisfied (use --upgrade to upgrade): six>=1.4.1 in ./lib/python2.7 (from cryptography)
Collecting setuptools>=11.3 (from cryptography)
  Using cached setuptools-22.0.5-py2.py3-none-any.whl
Collecting enum34 (from cryptography)
  Using cached enum34-1.1.6-py2-none-any.whl
Collecting ipaddress (from cryptography)
  Using cached ipaddress-1.0.16-py27-none-any.whl
Collecting cffi>=1.4.1 (from cryptography)
  Using cached cffi-1.6.0.tar.gz
Collecting pycparser (from cffi>=1.4.1->cryptography)
  Using cached pycparser-2.14.tar.gz
Installing collected packages: setuptools, enum34, ipaddress, pycparser, cffi, cryptography
  Found existing installation: setuptools 2.1
    Uninstalling setuptools-2.1:
Exception:
Traceback (most recent call last):
  File "/home/humanlink/lib/python2.7/pip-8.1.2-py2.7.egg/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/home/humanlink/lib/python2.7/pip-8.1.2-py2.7.egg/pip/commands/install.py", line 317, in run
    prefix=options.prefix_path,
  File "/home/humanlink/lib/python2.7/pip-8.1.2-py2.7.egg/pip/req/req_set.py", line 736, in install
    requirement.uninstall(auto_confirm=True)
  File "/home/humanlink/lib/python2.7/pip-8.1.2-py2.7.egg/pip/req/req_install.py", line 742, in uninstall
    paths_to_remove.remove(auto_confirm)
  File "/home/humanlink/lib/python2.7/pip-8.1.2-py2.7.egg/pip/req/req_uninstall.py", line 115, in remove
    renames(path, new_path)
  File "/home/humanlink/lib/python2.7/pip-8.1.2-py2.7.egg/pip/utils/__init__.py", line 267, in renames
    shutil.move(old, new)
  File "/usr/lib64/python2.7/shutil.py", line 302, in move
    os.unlink(src)
OSError: [Errno 13] Permission denied: '/usr/bin/easy_install-2.7'

How do I find out who the user is ? and if I wanted to set the user to me, who would the user be for the production server ? would it be the user I am currently logged in to on the computer ? or would it be an admin on Webfaction, the company who is hosting my domain ?


Solution

  • You should be root to install system-wide, if you can't you can just do

    pip install  --user  cryptography