OpenShift Django项目部署失败:“错误:无法在安装目录中创建或删除文件”
我在很长一段时间没有更新我的项目后,开始进行更新,但出现了一些问题。部署失败了,应用程序在执行 git push
后没有重新启动。
我仍然可以通过手动运行 gear start
来启动我的应用,但安装 install_requires
中的包所需的部署步骤却失败了。
以下是 gear deploy
输出的一部分:
Activating virtenv
Running setup.py script..
running develop
error: can't create or remove files in install directory
The following error occurred while trying to add or remove files in the
installation directory:
[Errno 13] Permission denied: '/usr/lib/python2.6/site-packages/test-easy-install-358943.write-test'
The installation directory you specified (via --install-dir, --prefix, or
the distutils default setting) was:
/usr/lib/python2.6/site-packages/
Perhaps your account does not have write access to this directory? If the
installation directory is a system-owned directory, you may need to sign in
as the administrator or "root" account. If you do not have administrative
access to this machine, you may wish to choose a different installation
directory, preferably one that is listed in your PYTHONPATH environment
variable.
For information on other options, you may wish to consult the
documentation at:
http://peak.telecommunity.com/EasyInstall.html
Please make the appropriate changes for your system and try again.
然后,后面出现了:
Running collectstatic...
Traceback (most recent call last):
File "~/app-root/runtime/repo//wsgi/music/manage.py", line 2, in <module>
from django.core.management import execute_manager
ImportError: No module named django.core.management
我尝试启用虚拟环境(venv)并手动运行 setup.py:
source $OPENSHIFT_GEAR_DIR/virtenv/bin/activate
export PYTHON_EGG_CACHE=$OPENSHIFT_GEAR_DIR/virtenv/lib/python-2.6
~/app-root/repo/setup.py develop
但是,这仍然导致了相同的 can't create or remove files in install directory
错误。而且我也无法像之前那样在这个环境中运行 manage.py
。
我觉得虚拟环境(venv)可能出了问题,但 gear start
也在使用它,而且它仍然可以正常工作...
有没有人能给我一些关于这个问题的要点?
附言:我正在使用 Python 2.6 的环境
1 个回答
0
总算搞定了。之前有点乱,主要是关于符号链接的问题。virtenv/lib64
指向了../../python-2.6/virtenv/lib
,这个链接只能从~/python-2.6
访问,而~/python-2.6
又是指向~/python
的一个符号链接,~/python
里面有个virtenv
,实际上是通过环境变量来引用的,这又是一个指向~/app-root/runtime/dependencies/python/virtenv
的符号链接。结果就是,virtenv的Python解释器找不到virtenv/lib64
里的库和其他东西,只好退回去用/usr
的内容。
我简单地把lib64
指向了lib
,现在部署就正常了。
不过,这一切混乱的情况似乎都是OpenShift工具链造成的,我不太确定它不会再出问题。