when I git push and rebuild my DIY application in OpenShift, the pip install failed, and the error is Permission Denied. does any one know why ?
I have no idea why pip will write the .pip in /var/lib/openshift/513b50c74382ec1582000797/
path.
remote: Building git ref 'master', commit 35344b7
remote: Requirement already satisfied (use --upgrade to upgrade): Flask==0.9 in ./app-root/data/lib/python2.7/site-packages (from -r /var/lib/openshift/513b50c74382ec1582000797/app-root/runtime/repo//requirements.txt (line 1))
remote: Requirement already satisfied (use --upgrade to upgrade): markdown in ./app-root/data/lib/python2.7/site-packages (from -r /var/lib/openshift/513b50c74382ec1582000797/app-root/runtime/repo//requirements.txt (line 2))
remote: Requirement already satisfied (use --upgrade to upgrade): tornado==1.2.1 in ./app-root/data/lib/python2.7/site-packages (from -r /var/lib/openshift/513b50c74382ec1582000797/app-root/runtime/repo//requirements.txt (line 3))
remote: Requirement already satisfied (use --upgrade to upgrade): uWSGI==1.4.4 in ./app-root/data/lib/python2.7/site-packages (from -r /var/lib/openshift/513b50c74382ec1582000797/app-root/runtime/repo//requirements.txt (line 4))
remote: Requirement already satisfied (use --upgrade to upgrade): PyRSS2Gen in ./app-root/data/lib/python2.7/site-packages (from -r /var/lib/openshift/513b50c74382ec1582000797/app-root/runtime/repo//requirements.txt (line 5))
remote: Requirement already satisfied (use --upgrade to upgrade): pygments in ./app-root/data/lib/python2.7/site-packages (from -r /var/lib/openshift/513b50c74382ec1582000797/app-root/runtime/repo//requirements.txt (line 6))
remote: Downloading/unpacking Flask-Cache==0.13 (from -r /var/lib/openshift/513b50c74382ec1582000797/app-root/runtime/repo//requirements.txt (line 7))
remote: Exception:
remote: Traceback (most recent call last):
remote: File "/var/lib/openshift/513b50c74382ec1582000797/app-root/data/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py", line 104, in main
remote: status = self.run(options, args)
remote: File "/var/lib/openshift/513b50c74382ec1582000797/app-root/data/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/commands/install.py", line 245, in run
remote: requirement_set.prepare_files(finder, force_root_egg_info=self.bundle, bundle=self.bundle)
remote: File "/var/lib/openshift/513b50c74382ec1582000797/app-root/data/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/req.py", line 971, in prepare_files
remote: location = req_to_install.build_location(self.build_dir, not self.is_download)
remote: File "/var/lib/openshift/513b50c74382ec1582000797/app-root/data/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/req.py", line 153, in build_locatio
remote: _make_build_dir(build_dir)
remote: File "/var/lib/openshift/513b50c74382ec1582000797/app-root/data/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/req.py", line 1225, in _make_build_dir
remote: os.makedirs(build_dir)
remote: File "/var/lib/openshift/513b50c74382ec1582000797/app-root/data/lib/python2.7/os.py", line 157, in makedirs
remote: mkdir(name, mode)
remote: OSError: [Errno 13] Permission denied: '/var/lib/openshift/513b50c74382ec1582000797/build'
remote:
remote: Storing complete log in /var/lib/openshift/513b50c74382ec1582000797/.pip/pip.log
remote: Traceback (most recent call last):
remote: File "/var/lib/openshift/513b50c74382ec1582000797/app-root/data//bin/pip", line 8, in <module>
remote: load_entry_point('pip==1.1', 'console_scripts', 'pip')()
remote: File "/var/lib/openshift/513b50c74382ec1582000797/app-root/data/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/__init__.py", line 116, in main
remote: return command.main(args[1:], options)
remote: File "/var/lib/openshift/513b50c74382ec1582000797/app-root/data/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py", line 141, in main
remote: log_fp = open_logfile(log_fn, 'w')
remote: File "/var/lib/openshift/513b50c74382ec1582000797/app-root/data/lib/python2.7/site-packages/pip-1.1-py2.7.egg/pip/basecommand.py", line 165, in open_logfile
remote: os.makedirs(dirname)
remote: File "/var/lib/openshift/513b50c74382ec1582000797/app-root/data/lib/python2.7/os.py", line 157, in makedirs
remote: mkdir(name, mode)
remote: OSError: [Errno 13] Permission denied: '/var/lib/openshift/513b50c74382ec1582000797/.pip'
remote: An error occurred executing 'gear postreceive' (exit code: 1)
remote: Error message: CLIENT_ERROR: Failed to execute action hook 'build' for 513b50c74382ec1582000797 application py27
remote:
remote: For more details about the problem, try running the command again with the '--trace' option.
looks like pip install by default tries to write some information into your home directory, which you don't have access to write to on openshift. Have you tried using one of the pre-built python cartridges? They are setup to correctly install packages that you define within your application.
If you are dead set on using a DIY gear, you might at least look at the code for the default python cartridges and see how they solve this same issue: https://github.com/openshift/origin-server/tree/master/cartridges