我正在 CentOS 5.8 上进行 Python 2.7.3 的 altinstall,我想要分发 pip 和所有爵士乐。但是,我无法理解正确的程序,并且分发的安装脚本给了我错误。
当前命令顺序:(最终将是用于我的项目的设置脚本)
sudo yum groupinstall "Development tools"
sudo yum install {zlib,bzip2,openssl,ncurses}-devel
cd /tmp && mkdir python273 && cd python273
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tar.bz2
tar -xf Python-2.7.3.tar.bz2
cd Python-2.7.3
./configure --prefix=/usr/local --enable-shared
make
sudo make altinstall # installs to /usr/local/{bin,lib}
# Fix path to shared lib - http://stackoverflow.com/a/7880519/1076493
echo "/usr/local/lib" | sudo tee -a /etc/ld.so.conf > /dev/null
sudo ldconfig
# Distribute
wget http://python-distribute.org/distribute_setup.py
sudo python2.7 distribute_setup.py
# Done, install whatever interesting packages I want + clean up
sudo pip install virtualenv yolk bpython
rm -rf /tmp/python273
但是,在尝试运行时我得到“权限被拒绝”distribute_setup.py
,即使它是使用 sudo 运行的。在 root shell 中执行此操作时工作正常。我猜这个脚本不尊重最初在制作子进程或其他东西时使用的 UID。
这让我想知道;当使用分发执行 Python (2.7.3) 的 altinstall 时,这是正确的顺序吗?或者仅仅是分发设置脚本不尊重给定的 UID?如果脚本是问题所在,我将如何使用 sudo 运行它,因为我不希望我的设置需要 root shell?
$ sudo python2.7 distribute_setup.py
Downloading http://pypi.python.org/packages/source/d/distribute/distribute-0.6.35.tar.gz
Extracting in /tmp/tmpE9UJke
Now working in /tmp/tmpE9UJke/distribute-0.6.35
Installing Distribute
Traceback (most recent call last):
File "distribute_setup.py", line 546, in <module>
sys.exit(main())
File "distribute_setup.py", line 543, in main
return _install(tarball, _build_install_args(options))
File "distribute_setup.py", line 87, in _install
if not _python_cmd('setup.py', 'install', *install_args):
File "distribute_setup.py", line 37, in _python_cmd
return subprocess.call(args) == 0
File "/usr/local/lib/python2.7/subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "/usr/local/lib/python2.7/subprocess.py", line 679, in __init__
errread, errwrite)
File "/usr/local/lib/python2.7/subprocess.py", line 1249, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied