Open VIM and run command:
:python print "Hello World!"
but failed with:
E448: Could not load library function _PyArg_Parse_SizeT
E263: Sorry, this command is disabled, the Python library could not be loaded.
My environment below:
OS: CentOS 7.3
Python2.7.13 Install:
wget -c https://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
tar -zxvf Python-2.7.13.tgz
cd Python-2.7.13
./configure
make
make install
Python3.6.1 Install:
wget -c https://www.python.org/ftp/python/3.6.1/Python-3.6.1.tgz
tar -zxvf Python-3.6.1.tgz
cd Python-3.6.1/
./configure
make
make install
VIM8.0 Install:
rpm -e $(rpm -qa | grep vim) --nodeps
git clone https://github.com/vim/vim.git
cd vim/src
./configure --with-features=huge --enable-pythoninterp --with-python-config-dir=/usr/local/lib/python2.7/config/ --enable-python3interp --with-python3-config-dir=/usr/local/lib/python3.6/config-3.6m-x86_64-linux-gnu/ --enable-multibyte --enable-cscope --enable-gui=auto --enable-xim --with-x --enable-fontset --disable-selinux
make
make install
vim --version | grep python
other
echo "alias vi='vim'" >> ~/.bashrc
echo "export PATH=/usr/local/bin:\$PATH" >> ~/.bashrc
source ~/.bashrc
Related
I tried to build wheel packages of NumPy and SciPy using Clang and Clang++ for RISC-V. I used cross-compilation on Ubuntu 20.04 under WSL.
Firstly, I built from sources LLVM from the standard repository, RISC-V GCC Toolchain from the branch rvv-next, and used these toolchains to build the latest OpenBLAS from sources.
After this, I install the virtual environment of a cross-compilation, and activated it.
Next, I installed necessary Python packages, and started building NumPy and SciPy.
As a result, I got the wheel package for NumPy, but the compilation error instead of the wheel package for SciPy. The compilation error is
scipy/spatial/qhull.c:10158:72: error: incompatible function pointer types passing 'void (*)(qhT *, void *, vertexT *, vertexT *, setT *, unsigned int)' (aka 'void (*)(struct qhT *, void *, struct vertexT *, struct vertexT *, struct setT *, unsigned int)') to parameter of type 'printvridgeT' (aka 'void (*)(struct qhT *, struct _IO_FILE *, struct vertexT *, struct vertexT *, struct setT *, unsigned int)') [-Wincompatible-function-pointer-types]
(void)(qh_eachvoronoi_all(__pyx_v_self->_qh, ((void *)__pyx_v_self), (&__pyx_f_5scipy_7spatial_5qhull__visit_voronoi), (__pyx_v_self->_qh[0]).UPPERdelaunay, qh_RIDGEall, 1));
The file scipy/spatial/qhull.c was generated by Cython, when the build process was running.
More precisely, I did like this:
cd ~
mkdir wheels-clang
cd wheels-clang
mkdir other-blas scripts
./scripts/build_gcc_and_clang.sh "$HOME/wheels-clang"
./scripts/download_build_and_install_openblas_using_llvm_toolchain.sh "$HOME/wheels-clang/other-blas" "$HOME/wheels-clang/other-blas/OpenBLAS/usr"
export SYSROOT=/opt/riscv/sysroot
export RISCV_GCC=$HOME/wheels-clang/scripts/llvm-clang-wrapper.sh
export RISCV_GPP=$HOME/wheels-clang/scripts/llvm-clang++-wrapper.sh
export RISCV_GFORTRAN=/opt/riscv/bin/riscv64-unknown-linux-gnu-gfortran
export RISCV_LD=/opt/riscv/bin/riscv64-unknown-linux-gnu-ld
export RISCV_AR=/opt/riscv/bin/riscv64-unknown-linux-gnu-ar
path-to-ubuntu-wsl-python3.9.14/bin/python3 -m pip install crossenv
path-to-ubuntu-wsl-python3.9.14/bin/python3 -m crossenv --cc $RISCV_GCC --cxx $RISCV_GPP --ar $RISCV_AR path-to-riscv-python3.9.14/bin/python riscv_cross_venv_stock
source riscv_cross_venv_stock/bin/activate
build-pip install wheel cython pybind11 pythran ply beniget gast pythran numpy==1.19.3
pip install wheel cython pybind11 pythran ply beniget gast pythran numpy==1.19.3
git clone --recurse-submodules -b v1.7.3 --depth 1 https://github.com/scipy/scipy.git
cd scipy/
echo '[openblas]' > site.cfg
echo 'libraries = openblas' >> site.cfg
echo "library_dirs = $HOME/wheels-clang/other-blas/OpenBLAS/usr/lib" >> site.cfg
echo "include_dirs = $HOME/wheels-clang/other-blas/OpenBLAS/usr/include" >> site.cfg
echo "runtime_library_dirs = $HOME/wheels-clang/other-blas/OpenBLAS/usr/lib" >> site.cfg
export BLAS_DIR=$HOME/wheels-clang/other-blas/OpenBLAS/usr/
export OPEN_BLAS_DIR=$HOME/wheels-clang/other-blas/OpenBLAS/usr/
export F90=$RISCV_GFORTRAN
export F77=$RISCV_GFORTRAN
export LD=$RISCV_LD
export CC=$HOME/wheels-clang/scripts/llvm-clang-wrapper.sh
export CXX=$HOME/wheels-clang/scripts/llvm-clang++-wrapper.sh
export LD_LIBRARY_PATH=$HOME/wheels-clang/other-blas/OpenBLAS/usr/lib:$LD_LIBRARY_PATH
export LDFLAGS="$LDFLAGS -L$HOME/wheels-clang/other-blas/OpenBLAS/usr/lib"
export CPPFLAGS="$CPPFLAGS -I$HOME/wheels-clang/other-blas/OpenBLAS/usr/include"
export PKG_CONFIG_PATH="$HOME/wheels-clang/other-blas/OpenBLAS/usr/lib/pkgconfig"
export BLAS=$HOME/wheels-clang/other-blas/OpenBLAS/usr/lib/libopenblas.so
pip wheel . -v -w ../wheels_stock
cd ..
cp riscv_cross_venv_stock/cross/lib/python3.9/site-packages/numpy/core/lib/libnpymath.a riscv_cross_venv_stock/build/lib/python3.9/site-packages/numpy/core/lib/libnpymath.a
cp riscv_cross_venv_stock/cross/lib/python3.9/site-packages/numpy/random/lib/libnpyrandom.a riscv_cross_venv_stock/build/lib/python3.9/site-packages/numpy/random/lib/libnpyrandom.a
cd scipy/
pip wheel . -v -w ../wheels_stock
I used the following scripts:
the script build_gcc_and_clang.sh:
#!/bin/bash
function install_prerequisites()
{
sudo apt -y install autoconf automake autotools-dev
sudo apt -y install libmpc-dev libmpfr-dev libgmp-dev
sudo apt -y install build-essential
sudo apt -y install bison flex
sudo apt -y install curl python3
sudo apt -y install texinfo gperf libtool patchutils bc
sudo apt -y install zlib1g-dev libexpat-dev
sudo apt -y install make cmake git-all
}
function create_installation_dirs()
{
sudo mkdir /opt/riscv
sudo chown -R $USER /opt/riscv
}
function download_and_build_gcc()
{
git clone https://github.com/riscv/riscv-gnu-toolchain --branch rvv-next
cd riscv-gnu-toolchain/
./configure --with-arch=rv64gcv --prefix=/opt/riscv --enable-linux
make linux
}
function download_and_build_llvm()
{
git clone https://github.com/llvm/llvm-project
cd llvm-project
mkdir build
cd build
cmake -G 'Unix Makefiles' -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/opt/riscv -DLLVM_TARGETS_TO_BUILD="RISCV" -DLLVM_DEFAULT_TARGET_TRIPLE="riscv64-unknown-linux-gnu" -DLLVM_ENABLE_PROJECTS="clang;llvm;lld;flang" ../llvm
make -j4
make install
}
DIR_FOR_SOURCES="$1"
if [ -z "$DIR_FOR_SOURCES" ]
then
DIR_FOR_SOURCES="$HOME"
fi
echo "The parent directory for GCC and LLVM sources: $DIR_FOR_SOURCES"
install_prerequisites
create_installation_dirs
cd "$DIR_FOR_SOURCES"
download_and_build_gcc
cd ..
download_and_build_llvm
cd ..
the script download_build_and_install_openblas_using_llvm_toolchain.sh:
#!/bin/bash
function clone_openblas()
{
git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS
sed -i 's/ifeq/#ifeq/g' Makefile.riscv64
sed -i 's/endif/#endif/g' Makefile.riscv64
sed -i 's/CCOMMON_OPT += -march=rv64imafdcv0p7_zfh_xtheadc -mabi=lp64d -mtune=c920/CCOMMON_OPT += --target=riscv64-unknown-linux-gnu -march=rv64gcv_zfh -mabi=lp64d --sysroot=$(SYSROOT)/g' Makefile.riscv64
sed -i 's/FCOMMON_OPT += -march=rv64imafdcv0p7_zfh_xtheadc -mabi=lp64d -mtune=c920 -static/FCOMMON_OPT += -march=rv64gcv_zfh -mabi=lp64d -static --sysroot=$(SYSROOT)/g' Makefile.riscv64
sed -i 's/TARGET_FLAGS = -march=rv64gcv0p7_zfh_xtheadc -mabi=lp64d/TARGET_FLAGS = --target=riscv64-unknown-linux-gnu -march=rv64gcv_zfh -mabi=lp64d/g' Makefile.prebuild
}
function setup_environment_vars()
{
HOSTCC=clang
CROSS_SUFFIX=llvm-
ROOT=/opt/riscv
CC=$ROOT/bin/clang
FC=/opt/riscv/bin/riscv64-unknown-linux-gnu-gfortran
AR=$ROOT/bin/${CROSS_SUFFIX}ar
RANLIB=$ROOT/bin/${CROSS_SUFFIX}ranlib
SYSROOT=/opt/riscv/sysroot
GCC_TOOLCHAIN=/opt/riscv
CFLAGS=" -fuse-ld=lld --gcc-toolchain=$GCC_TOOLCHAIN"
}
function build_openblas()
{
make -j4 TARGET=C910V CC=$CC FC=$FC AR=$AR RANLIB=$RANLIB HOSTCC=$HOSTCC SYSROOT=$SYSROOT CROSS_SUFFIX=$CROSS_SUFFIX CFLAGS="$CFLAGS" V=1
if ! [ -d "$1" ]
then
echo "The defined installation directory $1 does not exist and will be created."
mkdir -p "$1"
fi
make install PREFIX="$1"
cd ..
}
DIR_FOR_SOURCES="$1"
INSTALLATION_DIR="$2"
if [ -z "$DIR_FOR_SOURCES" ]
then
echo "A directory for OpenBLAS sources was not defined. The directory $HOME will be used by default."
DIR_FOR_SOURCES="$HOME"
fi
if [ -z "$INSTALLATION_DIR" ]
then
echo "Creating the default directory to install."
sudo mkdir /opt/OpenBLAS
sudo chown -R $USER /opt/OpenBLAS
INSTALLATION_DIR="/opt/OpenBLAS"
echo "A directory to install OpenBLAS was not defined. The directory $INSTALLATION_DIR will be used by default."
fi
echo "Directory for BLAS sources: $HOME"
echo "Installation directory: $INSTALLATION_DIR"
cd "$DIR_FOR_SOURCES"
clone_openblas
setup_environment_vars
build_openblas "$INSTALLATION_DIR"
echo "OpenBLAS was installed into $INSTALLATION_DIR"
the script llvm-clang-wrapper.sh:
#!/bin/bash
GCC_TOOLCHAIN=/opt/riscv
/opt/riscv/bin/clang --target=riscv64-unknown-linux-gnu -march=rv64gcv_zfh -mabi=lp64d -v --sysroot=$SYSROOT -fuse-ld=lld --gcc-toolchain=$GCC_TOOLCHAIN "$#"
the script llvm-clang++-wrapper.sh:
#!/bin/bash
GCC_TOOLCHAIN=/opt/riscv
/opt/riscv/bin/clang++ --target=riscv64-unknown-linux-gnu -march=rv64gcv_zfh -mabi=lp64d -v --sysroot=$SYSROOT -fuse-ld=lld --gcc-toolchain=$GCC_TOOLCHAIN "$#"
When I tried to use the standard Ubuntu cross-compilation GCC toolchain for RISC-V, I have no any compilation errors, and I get correct NumPy and SciPy packages for RISC-V.
More precisely, I did the following.
Install necessary deb-packages:
sudo apt install make cmake gcc g++ ccache gcc-riscv64-linux-gnu g++-riscv64-linux-gnu gfortran-riscv64-linux-gnu libgomp1-riscv64-cross libssl-dev meson
Download and build OpenBLAS:
mkdir wheels
cd wheels/
git clone https://github.com/xianyi/OpenBLAS.git
cd OpenBLAS/
sed -i "s/CCOMMON_OPT += -march=rv64imafdcv0p7_zfh_xtheadc -mabi=lp64d -mtune=c920/CCOMMON_OPT += -march=rv64imafdc -mabi=lp64d/g" Makefile.riscv64
sed -i "s/FCOMMON_OPT += -march=rv64imafdcv0p7_zfh_xtheadc -mabi=lp64d -mtune=c920 -static/FCOMMON_OPT += -march=rv64imafdc -mabi=lp64d -static/g" Makefile.riscv64
make -j4 HOSTCC=gcc CC=riscv64-linux-gnu-gcc FC=riscv64-linux-gnu-gfortran ARCH=riscv64 TARGET=RISCV64_GENERIC
mkdir usr
make PREFIX=$HOME/wheels/OpenBLAS/usr/ install
Set up some environment variables:
export RISCV_GCC=riscv64-linux-gnu-gcc
export RISCV_GPP=riscv64-linux-gnu-g++
export RISCV_GFORTRAN=riscv64-linux-gnu-gfortran
export RISCV_LD=riscv64-linux-gnu-ld
export RISCV_AR=riscv64-linux-gnu-ar
Install crossenv package and create a virtual environment:
path-to-ubuntu-wsl-python3.9.14/bin/python3 -m pip install crossenv
path-to-ubuntu-wsl-python3.9.14/bin/python3 -m crossenv --cc $RISCV_GCC --cxx $RISCV_GPP --ar $RISCV_AR path-to-riscv-python3.9.14/bin/python riscv_cross_venv_stock
source riscv_cross_venv_stock/bin/activate
build-pip install wheel cython pybind11 pythran ply beniget gast pythran numpy==1.19.3
pip install wheel cython pybind11 pythran ply beniget gast pythran numpy==1.19.3
cd ..
Clone SciPy:
git clone --recurse-submodules -b v1.7.3 --depth 1 https://github.com/scipy/scipy.git
cd scipy
Create the file site.cfg:
echo '[openblas]' >> site.cfg
echo 'libraries = openblas' >> site.cfg
echo "library_dirs = $HOME/wheels/OpenBLAS/usr/lib" >> site.cfg
echo "include_dirs = $HOME/wheels/OpenBLAS/usr/include" >> site.cfg
echo "runtime_library_dirs = $HOME/wheels/OpenBLAS/usr/lib" >> site.cfg
Set up the following environment variables:
export BLAS_DIR=$HOME/wheels/OpenBLAS/usr/
export OPEN_BLAS_DIR=$HOME/wheels/OpenBLAS/usr/
export F90=$RISCV_GFORTRAN
export F77=$RISCV_GFORTRAN
export LD=$RISCV_LD
export LD_LIBRARY_PATH=$HOME/wheels/OpenBLAS/usr/lib:$LD_LIBRARY_PATH
Build NumPy and SciPy:
pip wheel . -v -w ../wheels_stock
cd ../OpenBLAS/
cp riscv_cross_venv_stock/cross/lib/python3.9/site-packages/numpy/core/lib/libnpymath.a riscv_cross_venv_stock/build/lib/python3.9/site-packages/numpy/core/lib/libnpymath.a
cp riscv_cross_venv_stock/cross/lib/python3.9/site-packages/numpy/random/lib/libnpyrandom.a riscv_cross_venv_stock/build/lib/python3.9/site-packages/numpy/random/lib/libnpyrandom.a
cd ~/wheels/scipy/
pip wheel . -v -w ../wheels_stock
As a result, I got the correct wheel packages of NumPy and SciPy for RISC-V.
Also, I tried to use Clang/Clang++ and GFortran compiler from the standard Ubuntu 20.04 repos, but I got the strange linker error. Unfortunately, I forgot it.
I would like to know how I can build NumPy and SciPy using cross-compilation with Clang for RISC-V target machine.
I need a Dockerfile to run my Python script. The script uses Selenium, so I need to load a driver for it to work. An ordinary .exe file - driver is not suitable, so according to the advice of the administrators of the hosting where the script is located I need to create a Dockerfile for the script to work properly.
The main problem is that I simply can not run my script, because I do not understand how to load the required driver on the server.
This is a sample code of what should be in the Dockerfile.
FROM python:3
RUN apt-get update -y
RUN apt-get install -y wget
RUN wget -O $HOME/geckodriver.tar.gz https://github.com/mozilla/geckodriver/releases/download/v0.23.0/geckodriver-v0.23.0-linux64.tar.gz
RUN tar xf $HOME/geckodriver.tar.gz -C $HOME
RUN cp $HOME/geckodriver /usr/local/bin/geckodriver
RUN chmod +x /usr/local/bin/geckodriver
RUN rm -f $HOME/geckodriver $HOME/geckodriver.tar.gz
This is the code used in the Python script
options = Options()
options.add_argument('headless')
options.add_argument('window-size=1920x935')
driver = webdriver.Chrome(options=options, executable_path=r"chromedriver.exe")
driver.get(f"https://www.wildberries.ru/catalog/{id}/feedbacks?imtId={imt_id}")
time.sleep(5)
big_stat = driver.find_element(by=By.CLASS_NAME, value="rating-product__numb")
I can redo this snippet of code to make it work on Firefox, if necessary.
This is what the directories of the hosting where all the files are located look like
The directories of the hosting
For getting Selenium to work with Python using a Dockerfile, here's an existing SeleniumBase Dockerfile.
For instructions on using it, see the README.
For building, it's basically this:
Non Apple M1 Mac:
docker build -t seleniumbase .
If running on an Apple M1 Mac, use this instead:
docker build --platform linux/amd64 seleniumbase .
Before building the Dockerfile, you'll need to clone SeleniumBase.
Here's what the Dockerfile currently looks like:
FROM ubuntu:18.04
#=======================================
# Install Python and Basic Python Tools
#=======================================
RUN apt-get -o Acquire::Check-Valid-Until=false -o Acquire::Check-Date=false update
RUN apt-get install -y python3 python3-pip python3-setuptools python3-dev python-distribute
RUN alias python=python3
RUN echo "alias python=python3" >> ~/.bashrc
#=================================
# Install Bash Command Line Tools
#=================================
RUN apt-get -qy --no-install-recommends install \
sudo \
unzip \
wget \
curl \
libxi6 \
libgconf-2-4 \
vim \
xvfb \
&& rm -rf /var/lib/apt/lists/*
#================
# Install Chrome
#================
RUN curl -sS -o - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list && \
apt-get -yqq update && \
apt-get -yqq install google-chrome-stable && \
rm -rf /var/lib/apt/lists/*
#=================
# Install Firefox
#=================
RUN apt-get -qy --no-install-recommends install \
$(apt-cache depends firefox | grep Depends | sed "s/.*ends:\ //" | tr '\n' ' ') \
&& rm -rf /var/lib/apt/lists/* \
&& cd /tmp \
&& wget --no-check-certificate -O firefox-esr.tar.bz2 \
'https://download.mozilla.org/?product=firefox-esr-latest&os=linux64&lang=en-US' \
&& tar -xjf firefox-esr.tar.bz2 -C /opt/ \
&& ln -s /opt/firefox/firefox /usr/bin/firefox \
&& rm -f /tmp/firefox-esr.tar.bz2
#===========================
# Configure Virtual Display
#===========================
RUN set -e
RUN echo "Starting X virtual framebuffer (Xvfb) in background..."
RUN Xvfb -ac :99 -screen 0 1280x1024x16 > /dev/null 2>&1 &
RUN export DISPLAY=:99
RUN exec "$#"
#=======================
# Update Python Version
#=======================
RUN apt-get update -y
RUN apt-get -qy --no-install-recommends install python3.8
RUN rm /usr/bin/python3
RUN ln -s python3.8 /usr/bin/python3
#=============================================
# Allow Special Characters in Python Programs
#=============================================
RUN export PYTHONIOENCODING=utf8
RUN echo "export PYTHONIOENCODING=utf8" >> ~/.bashrc
#=====================
# Set up SeleniumBase
#=====================
COPY sbase /SeleniumBase/sbase/
COPY seleniumbase /SeleniumBase/seleniumbase/
COPY examples /SeleniumBase/examples/
COPY integrations /SeleniumBase/integrations/
COPY requirements.txt /SeleniumBase/requirements.txt
COPY setup.py /SeleniumBase/setup.py
RUN find . -name '*.pyc' -delete
RUN find . -name __pycache__ -delete
RUN pip3 install --upgrade pip
RUN pip3 install --upgrade setuptools
RUN pip3 install --upgrade setuptools-scm
RUN cd /SeleniumBase && ls && pip3 install -r requirements.txt --upgrade
RUN cd /SeleniumBase && pip3 install .
#=====================
# Download WebDrivers
#=====================
RUN wget https://github.com/mozilla/geckodriver/releases/download/v0.31.0/geckodriver-v0.31.0-linux64.tar.gz
RUN tar -xvzf geckodriver-v0.31.0-linux64.tar.gz
RUN chmod +x geckodriver
RUN mv geckodriver /usr/local/bin/
RUN wget https://chromedriver.storage.googleapis.com/2.44/chromedriver_linux64.zip
RUN unzip chromedriver_linux64.zip
RUN chmod +x chromedriver
RUN mv chromedriver /usr/local/bin/
#==========================================
# Create entrypoint and grab example tests
#==========================================
COPY integrations/docker/docker-entrypoint.sh /
COPY integrations/docker/run_docker_test_in_firefox.sh /
COPY integrations/docker/run_docker_test_in_chrome.sh /
RUN chmod +x *.sh
COPY integrations/docker/docker_config.cfg /SeleniumBase/examples/
ENTRYPOINT ["/docker-entrypoint.sh"]
CMD ["/bin/bash"]
Trying to use tox to run tests before pushing, but I keep running into errors like:
ERROR: py26: InterpreterNotFound: python2.6
ERROR: py32: InterpreterNotFound: python3.2
ERROR: py34: InterpreterNotFound: python3.3
apt-cache search isn't offering any packages that look like they will help. How do you load all these versions of the interpreter for ubuntu14.04?
Obviously, Ubuntu doesn't ship all historic versions of Python. But you can use deadsnakes PPA which has everything from 2.3 to 3.4.
For one project I used drone.io CI service with, I had the following tox section I ran before actual test envs.
[testenv:setupdrone]
whitelist_externals = /bin/bash
commands =
bash -c "echo 'debconf debconf/frontend select noninteractive' | sudo debconf-set-selections"
bash -c "sudo add-apt-repository ppa:fkrull/deadsnakes &> /dev/null"
bash -c "sudo apt-get update &> /dev/null"
bash -c "sudo apt-get -y install python2.6 python3.4 &> /dev/null"
I need to force a virtualenv to use a compiled source python on my ci server (long story short: travis ci support python 2.7.3. heroku works with 2.7.6 and we insist on testing in the same environment as production) . But I fail to get virtualenv to run against it.
travis first runs this script:
if [ ! -d ./compiled ]; then
echo "creating compiled folder"
mkdir compiled
else
echo "compiled exists"
fi
cd compiled
if [ ! -e Python-2.7.6.tar.xz ]; then
echo "Downloading python and compiling"
wget http://www.python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz
tar xf Python-2.7.6.tar.xz
cd Python-2.7.6
./configure
make
chmod +x ./python
else
echo "Compiled python exists!"
fi
and then:
- virtualenv -p ./python ./compiled/python276
- source ./compiled/python276/bin/activate
but when then doing python --version shows 2.7.3 instead of 2.7.6
Guess I'm missing something, Thanks for the help!
Go to the virtualenv folder, and open bin/ folder:
~/.Virtualenv/my_project/bin
Remove 'python' file, and create a symbolic link to the python executable, that you want to use, like:
cd ~/.Virtualenv/my_project/bin
mv python python-bkp
ln -s /usr/bin/python .
I've been through several StackOverflow questions about Python & bzip2. These have been very helpful in getting me to the state I'm clearly at now. Here's what I've done so far and the problem I'm having:
I do not have root access and cannot install libbz2-dev(el)
/usr/bin/bzip2 is version 1.0.3
/usr/bin/python is version 2.4.3
GNU Stow is being used to manage libraries similar to how homebrew works
I need Python 2.7.3 to install with the bzip2 module in order to properly compile node.js from source. And yes, I'm sorry, but I do actually have to do all of this as a regular user from source.
I have installed bzip2 from source as follows:
$ make -f Makefile-libbz2_so
$ make
$ make install PREFIX=${STOW}/bzip2-1.0.6
$ cp libbz2.so.1.0.6 ${STOW}/bzip2-1.0.6/lib/
$ cd ${STOW}/bzip2-1.0.6/lib
$ ln -s libbz2.so.1.0.6 libbz2.so.1.0
$ cd ${STOW}
$ stow bzip2-1.0.6
I have stow's root directory in my PATH before anything else, so this results in:
$ bzip2 -V
# [...] Version 1.0.6
Which indicates that the correct bzip2 is being utilized in my PATH.
Next I move on to compiling Python from source and run the following:
$ cd Python-2.7.3
$ ./configure --prefix=${STOW}/Python-2.7.3
$ make
# Complains about several missing modules, of which "bz2" is the one I care about
$ make install prefix=${STOW}/Python-2.7.3 # unimportant as bz2 module failed to install
What is the correct way to tell Python during it's source configuration where the source installed bzip 1.0.6 library lives so it will detect the bzip2 devel headers and install the module properly?
Alright, it took me a few months to get to this, but I'm finally back and managed to tackle this problem.
Install bzip2 from source:
# Upload bzip2-1.0.6.tar.gz to ${SRC}
$ cd ${SRC}
$ tar -xzvf bzip2-1.0.6.tar.gz
$ cd bzip2-1.0.6
$ export CFLAGS="-fPIC"
$ make -f Makefile-libbz2_so
$ make
$ make install PREFIX=${STOW}/bzip2-1.0.6
$ cp libbz2.so.1.0.6 ${STOW}/bzip2-1.0.6/lib/
$ cd ${STOW}/bzip2-1.0.6/lib
$ ln -s libbz2.so.1.0.6 libbz2.so.1.0
$ cd ${STOW}
$ stow bzip2-1.0.6
$ source ${HOME}/.bash_profile
$ bzip2 --version
#=> bzip2, a block-soring file compressor. Version 1.0.6...
Install Python from source:
# Upload Python-2.7.3.tar.gz to ${SRC}
$ cd ${SRC}
$ tar -xzvf Python-2.7.3.tar.gz
$ cd Python-2.7.3
$ export CLFAGS="-fPIC"
$ export C_INCLUDE_PATH=${STOW}/../include
$ export CPLUS_INCLUDE_PATH=${C_INCLUDE_PATH}
$ export LIBRARY_PATH=${STOW}/../lib
$ export LD_RUN_PATH=${LIBRARY_PATH}
$ ./configure --enable-shared --prefix=${STOW}/Python-2.7.3 --libdir=${STOW}/../lib
$ make
$ make install prefix=${STOW}/Python-2.7.3
$ cd ${STOW}
$ stow Python-2.7.3
$ source ${HOME}/.bash_profile
$ python -V
#=> Python 2.7.3
$ python -c "import bz2; print bz2.__doc__"
#=> The python bz2 module provides...
Although node.js wasn't technically part of the question, it is what drove me to go through all of the above so I may as well include the last few commands to get node.js installed from source using a source install Python 2.7.3 & bzip2 1.0.6:
Install node.js from source:
# Upload node-v0.10.0.tar.gz to ${SRC}
$ cd ${SRC}
$ tar -xzvf node-v0.10.0.tar.gz
$ cd node-v0.10.0
$ ./configure --prefix=${STOW}/node-v0.10.0
$ make
$ make install prefix=${STOW}/node-v0.10.0
$ cd ${STOW}
$ stow node-v0.10.0
$ source ${HOME}/.bash_profile
$ node -v
#=> v0.10.0