![](/img/trans.png)
[英]OpenShift - URLError: <urlopen error [Errno 13] Permission denied>
[英]Openshift [Errno 13] Permission denied
我在此鏈接中遇到了完全相同的問題: pip install在OpenShift中失敗,錯誤信息是Permission Denied 。 在將django-oscar
部署到openshift時遇到了錯誤。 為了簡化此問題,我通過創建新墨盒進行了測試。 然后通過ssh訪問我的openshift服務器以執行下一個命令: pip install django-oscar
。 它的開頭很好,但結局不好,如以下代碼所示:
mrju@mrju:~/Documents/My_Project/My_Website/Oscar_Test$ rhc app create oscartest python-2.7
RSA 1024 bit CA certificates are loaded due to old openssl compatibility
Application Options
-------------------
Domain: mrju
Cartridges: python-2.7
Gear Size: default
Scaling: no
Creating application 'oscartest' ... done
Waiting for your DNS name to be available ... done
Cloning into 'oscartest'...
The authenticity of host 'oscartest-mrju.rhcloud.com (52.3.216.108)' can't be established.
RSA key fingerprint is cf:ee:77:cb:0e:fc:02:d7:72:7e:ae:80:c0:90:88:a7.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'oscartest-mrju.rhcloud.com,52.3.216.108' (RSA) to the list of known hosts.
Your application 'oscartest' is now available.
mrju@mrju:~/Documents/My_Project/My_Website/Oscar_Test$ ssh 5773c52c2d52710e5e00024a@oscartest-mrju.rhcloud.com
*********************************************************************
You are accessing a service that is for use only by authorized users.
If you do not have authorization, discontinue use at once.
Any use of the services is subject to the applicable terms of the
agreement which can be found at:
https://www.openshift.com/legal
*********************************************************************
Welcome to OpenShift shell
This shell will assist you in managing OpenShift applications.
!!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!
Shell access is quite powerful and it is possible for you to
accidentally damage your application. Proceed with care!
If worse comes to worst, destroy your application with "rhc app delete"
and recreate it
!!! IMPORTANT !!! IMPORTANT !!! IMPORTANT !!!
Type "help" for more info.
[oscartest-mrju.rhcloud.com 5773c52c2d52710e5e00024a]\>
[oscartest-mrju.rhcloud.com 5773c52c2d52710e5e00024a]\> cd /var/lib/openshift/5773c52c2d52710e5e00024a/python//virtenv/
[oscartest-mrju.rhcloud.com virtenv]\> ls
bin include lib lib64 pip-selfcheck.json
[oscartest-mrju.rhcloud.com virtenv]\> source bin/activate
(virtenv)[oscartest-mrju.rhcloud.com virtenv]\> pip install django-oscar
***The directory '/var/lib/openshift/5773c52c2d52710e5e00024a/.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.***
You are using pip version 7.1.0, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The directory '/var/lib/openshift/5773c52c2d52710e5e00024a/.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.
Collecting django-oscar
Downloading django_oscar-1.2.1-py2.py3-none-any.whl (5.6MB)
100% |████████████████████████████████| 5.6MB 39kB/s
Collecting phonenumbers<8.0.0,>=6.3.0 (from django-oscar)
Downloading phonenumbers-7.4.3.tar.gz (2.3MB)
100% |████████████████████████████████| 2.3MB 81kB/s
Collecting factory-boy<2.7,>=2.4.1 (from django-oscar)
Downloading factory_boy-2.6.1-py2.py3-none-any.whl
Collecting purl>=0.7 (from django-oscar)
Downloading purl-1.3-py2.py3-none-any.whl
Collecting mock<2.0,>=1.0.1 (from django-oscar)
Downloading mock-1.3.0-py2.py3-none-any.whl (56kB)
100% |████████████████████████████████| 57kB 3.7MB/s
Collecting django<1.9,>=1.7.8 (from django-oscar)
Downloading Django-1.8.13-py2.py3-none-any.whl (6.2MB)
100% |████████████████████████████████| 6.2MB 61kB/s
Collecting django-haystack<2.5.0,>=2.3.1 (from django-oscar)
Downloading django_haystack-2.4.1-py2-none-any.whl (95kB)
100% |████████████████████████████████| 98kB 3.9MB/s
Collecting django-treebeard>=3.0 (from django-oscar)
Downloading django-treebeard-4.0.1.tar.gz (93kB)
100% |████████████████████████████████| 94kB 2.6MB/s
Collecting django-extra-views<0.6.5,>=0.2 (from django-oscar)
Downloading django_extra_views-0.6.4-py27-none-any.whl
Collecting pillow>=1.7.8 (from django-oscar)
Downloading Pillow-3.2.0.zip (10.5MB)
100% |████████████████████████████████| 10.5MB 22kB/s
Collecting Unidecode<0.05,>=0.04.12 (from django-oscar)
Downloading Unidecode-0.04.19.tar.gz (204kB)
100% |████████████████████████████████| 204kB 1.4MB/s
Collecting sorl-thumbnail==12.3 (from django-oscar)
Downloading sorl_thumbnail-12.3-py2.py3-none-any.whl (40kB)
100% |████████████████████████████████| 40kB 4.2MB/s
Collecting django-tables2<1.1,>=1.0.4 (from django-oscar)
Downloading django-tables2-1.0.7.tar.gz (966kB)
100% |████████████████████████████████| 970kB 343kB/s
Collecting Babel<3.0,>=1.0 (from django-oscar)
Downloading Babel-2.3.4-py2.py3-none-any.whl (7.1MB)
100% |████████████████████████████████| 7.1MB 46kB/s
Collecting django-widget-tweaks>=1.4.1 (from django-oscar)
Downloading django_widget_tweaks-1.4.1-py2.py3-none-any.whl
Collecting fake-factory>=0.5.0 (from factory-boy<2.7,>=2.4.1->django-oscar)
Downloading fake_factory-0.5.8-py2.py3-none-any.whl (505kB)
100% |████████████████████████████████| 507kB 618kB/s
Requirement already satisfied (use --upgrade to upgrade): six in /opt/rh/python27/root/usr/lib/python2.7/site-packages (from purl>=0.7->django-oscar)
Collecting funcsigs (from mock<2.0,>=1.0.1->django-oscar)
Downloading funcsigs-1.0.2-py2.py3-none-any.whl
Collecting pbr>=0.11 (from mock<2.0,>=1.0.1->django-oscar)
Downloading pbr-1.10.0-py2.py3-none-any.whl (96kB)
100% |████████████████████████████████| 98kB 3.5MB/s
Collecting pytz>=0a (from Babel<3.0,>=1.0->django-oscar)
Downloading pytz-2016.4-py2.py3-none-any.whl (480kB)
100% |████████████████████████████████| 483kB 404kB/s
Collecting python-dateutil>=2.4 (from fake-factory>=0.5.0->factory-boy<2.7,>=2.4.1->django-oscar)
Downloading python_dateutil-2.5.3-py2.py3-none-any.whl (201kB)
100% |████████████████████████████████| 204kB 1.1MB/s
Collecting ipaddress (from fake-factory>=0.5.0->factory-boy<2.7,>=2.4.1->django-oscar)
Downloading ipaddress-1.0.16-py27-none-any.whl
Building wheels for collected packages: phonenumbers, django-treebeard, pillow, Unidecode, django-tables2
Exception:
Traceback (most recent call last):
File "/var/lib/openshift/5773c52c2d52710e5e00024a/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/pip/basecommand.py", line 223, in main
status = self.run(options, args)
File "/var/lib/openshift/5773c52c2d52710e5e00024a/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/pip/commands/install.py", line 293, in run
wb.build(autobuilding=True)
File "/var/lib/openshift/5773c52c2d52710e5e00024a/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/pip/wheel.py", line 756, in build
ensure_dir(output_dir)
File "/var/lib/openshift/5773c52c2d52710e5e00024a/app-root/runtime/dependencies/python/virtenv/lib/python2.7/site-packages/pip/utils/__init__.py", line 70, in ensure_dir
os.makedirs(path)
File "/var/lib/openshift/5773c52c2d52710e5e00024a/python/virtenv/lib64/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/var/lib/openshift/5773c52c2d52710e5e00024a/python/virtenv/lib64/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/var/lib/openshift/5773c52c2d52710e5e00024a/python/virtenv/lib64/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/var/lib/openshift/5773c52c2d52710e5e00024a/python/virtenv/lib64/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/var/lib/openshift/5773c52c2d52710e5e00024a/python/virtenv/lib64/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/var/lib/openshift/5773c52c2d52710e5e00024a/python/virtenv/lib64/python2.7/os.py", line 150, in makedirs
makedirs(head, mode)
File "/var/lib/openshift/5773c52c2d52710e5e00024a/python/virtenv/lib64/python2.7/os.py", line 157, in makedirs
mkdir(name, mode)
OSError: [Errno 13] Permission denied: '/var/lib/openshift/5773c52c2d52710e5e00024a/.cache'
(virtenv)[oscartest-mrju.rhcloud.com virtenv]\>
提示非常有用
The directory '/var/lib/openshift/5773c52c2d52710e5e00024a/.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.
You are using pip version 7.1.0, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The directory '/var/lib/openshift/5773c52c2d52710e5e00024a/.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.
但是我不知道如何獲得sudo的許可或如何使用sudo的-H標志。
如果您是在虛擬環境中使用pip
(根據發布的代碼來判斷),請不要使用sudo
,因為這將使軟件包整體安裝,而不是在虛擬環境中安裝。
相反,您可以將pip
與--user
標志一起使用,如下所示:
pip install --user <package_name>
如果失敗,請嘗試按照建議的回溯方式升級pip
,然后嘗試重新安裝
嘗試pip install django-oscar --no-cache-dir
sudo用於以root狀態執行命令。 您可以像sudo ls
之前簡單地使用sudo編寫命令。
對於您的問題,我認為pip沒有.cache的執行權限(如果您具有文件的執行權限,那么您可以執行此權限,對於目錄可以執行該權限。要解決此問題,請添加sudo chmod的許可權和所需的值。
chmod采用權利值給定的數字,例如777等。 chmod rwx rwx rwx
chmod用戶組other:每個具有boolean值(0或1)執行讀寫操作,例如:chmod 750表示用戶具有所有權限(111),組僅具有讀取和執行權限(101)以及其他任何權限。
您還可以使用sudo chmod +x name
添加權限x
如果您不知道標志,請首先嘗試使用man
命令。
man sudo
:
-H(HOME)選項選項將HOME環境變量設置為密碼數據庫指定的目標用戶的主目錄(默認為root)。 HOME環境變量的默認處理取決於sudoers(5)設置。 默認情況下,如果設置了env_reset或always_set_home,或者如果設置了set_home且在命令行上指定了-s選項,則sudo將設置HOME。
因此,請嘗試使用簡單的sudo pip install django-oscar
或su
命令在當前會話期間成為root用戶。
萬一將來有人遇到這個問題,這對我有幫助- 在此處輸入鏈接說明
這是鏈接的詳細信息-
這是我設法使用OpenShift動作鈎子找到的修復程序。 下面的代碼列表列出了幫助的關鍵Web鏈接。
詳細說明:
.openshift\\action_hooks
build
的文件添加到本地.openshift\\action_hooks
文件夾.openshift\\action_hooks
# !/bin/bash
# Written by Priyend Somaroo, 06 Jun 2016, Vardaan Enterpises, www.vardaan.com
#
# This will execute pip install but using no caching in order to fix broken
# cache problems with python-2.7 cartridge as at 06 Jun 2016
#
# Ref: http://stackoverflow.com/questions/29913677/openshift-app-with-flask-sqlalchemy-and-sqlite-problems-with-database-reverti
# Ref: http://stackoverflow.com/questions/21691202/how-to-create-file-execute-mode-permissions-in-git-on-windows
#
#
# *** Very important *** : this file must be marked executable using 'chmod +x'.
# In Windows this is a problem so we simply mark it in the git repo as executable as follows.
# - In Windows open command prompt and change to the folder with this build file
# - Then run 'git update-index --chmod=+x build'
# - Ten check the permissions aer 0755 using 'git ls-files --stage' .
#
# Normal commits and push's occur after that.
# This build hook gets executed at the end of the build cycle before delpoy
# Change to repo directory and run pip install with no caching
cd ${OPENSHIFT_REPO_DIR}
pip install -r requirements.txt --no-cache-dir
chmod +x build
git update-index --chmod=+x build
您可以通過ssh'進入您的應用文件夾並運行以下命令來確認安裝了正確的軟件包: pip list
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.