I tried installing Python 2.7 without root on a remote linux machine. I ran the commands
./configure prefix=/
make install DESTDIR=/xxx/yyy/
where /xxx/yyy/ is a directory for which I have read-write access.
I ran into a problem at the end. It said:
building dbm using gdbm INFO: Can't locate Tcl/Tk libs and/or headers
Python build finished, but the necessary bits to build these modules were not found: _tkinter bsddb185 dl imageop sunaudiodev To find the necessary bits, look in setup.py in detect_modules() for the module's name.
running build_scripts running install_lib creating /lib/python2.7 error: could not create '/lib/python2.7': Permission denied
Did I take the correct steps in installing it without root access? (i.e., my configure and make commands?) Can anyone tell me why it would not install properly?
Thanks,
ktm
PIP is automatically installed with Python 2.7.9+ and Python 3.4+ and it comes with the virtualenv and pyvenv virtual environments.
I wrote a script that installs Python 2 (which is missing the convenience faculties provided by Python 3 for user installations) and Pip 2 into a user directory so that a standard user can be administrator over its modules etc.
#!/bin/bash
VERSION="2.7.11"
BUILDDIR=~/"build/python"
INSTALLDIR=~/"python/Python-$VERSION"
mkdir -p ${BUILDDIR}
cd ${BUILDDIR}
if [ ! -f $BUILDDIR/Python-$VERSION.tgz ]
then
wget https://www.python.org/ftp/python/$VERSION/Python-$VERSION.tgz
tar zxfv Python-$VERSION.tgz
fi
find $BUILDDIR -type d | xargs chmod 0755
cd Python-$VERSION
mkdir -p ${INSTALLDIR}
./configure --prefix=${INSTALLDIR}
make && make install
# Append to user PATH or create symbolic link to .local/bin
# [[ ":$PATH:" != *":$HOME/python/Python-$VERSION/bin:"* ]] && printf "export PATH=$HOME/python/Python-$VERSION/bin:$PATH\n" >> ~/.bashrc
if [ ! -d ~/.local/bin ]; then mkdir -p ~/.local/bin; fi
ln -s ~/python/Python-"$VERSION"/bin/python ~/.local/bin/
source ~/.bashrc
# Install local pip
cd ..
wget --no-check-certificate https://bootstrap.pypa.io/get-pip.py -O - | python - --user
[[ ":$PATH:" != *":$HOME/.local/bin:"* ]] && printf "export PATH=$HOME/.local/bin:$PATH\n" >> ~/.bashrc
# Install modules like this:
# pip install --target="$HOME/.local/lib/python$VERSION/site-packages"
# Add those modules to PYTHONPATH
[[ ":$PYTHONPATH:" != *":$HOME/.local/lib/python$VERSION/site-packages:"* ]] && printf "export PYTHONPATH=$HOME/.local/lib/python$VERSION/site-packages:$PYTHONPATH\n" >> ~/.bashrc
source ~/.bashrc
Caveat: This script is admittedly opinionated in that it will append a few lines to your ~/.bashrc
for the PATH ENV variable. If this is not desired, simply comment the related lines in the script.
Case: The service file generator for Airprint service files for use in Avahi does not support Python 3. For the purpose of keeping the system clean, I just install a local version of Python 2 and run airprint-generate.py
followed by deleting the whole install (saves space on a small Raspberry Pi Zero W).
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