I'm doing an altinstall of Python 2.7.3 on CentOS 5.8, and I want distribute which gives pip and all that jazz. However I'm having trouble understanding the correct procedure, and the setup script for distribute is giving me errors.
The current order of commands: (will ultimately be a setup script used for a project of mine)
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
However I'm getting "permission denied" when trying to run the distribute_setup.py
, even though it's run with sudo. It's working fine when doing it in a root shell. I'm guessing the script doesn't respect the UID initially used when making a subprocess or something.
This makes me wonder; is this the right order when doing an altinstall of Python (2.7.3) with distribute? Or is it simply that the distribute setup script doesn't respect the given UID? If the script is the problem, how would I go about running it with sudo, since I don't want my setup to require a 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
I have a very similar setup here on RHEL5.8, and I get the same permission denied exception when I execute:
$ sudo python2.7 distribute_setup.py
The problem is solved by using an absolute path:
$ sudo /usr/local/bin/python2.7 distribute_setup.py
The underlying issue is simply that the root account doesn't have /usr/local/bin in it's PATH.
Indeed distribute_setup.py
tries to invoke a python subcommand by reusing the current python interpreter with sys.executable and subprocess.call, and if you try it step by step:
$ sudo python2.7 -c "import sys; print sys.executable"
$ sudo /usr/local/bin/python2.7 -c "import sys; print sys.executable"
/usr/local/bin/python2.7
The permission denied error is a bit misleading, but it is caused by trying to execute an empty filename:
$ python2.7 -c "import subprocess; subprocess.call([''])"
[...]
OSError: [Errno 13] Permission denied
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With