Last active
April 3, 2023 08:15
-
-
Save ctokheim/4507404 to your computer and use it in GitHub Desktop.
Bash (shell): Install local python
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
######################################### | |
# Installing python and necessary packages | |
# locally. This script will install python | |
# into the ~/local/bin directory and install | |
# numpy + scipy | |
######################################### | |
# installing python 2.7.3 | |
mkdir -p ~/local | |
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz | |
tar xvzf Python-2.7.3.tgz | |
cd Python-2.7.3 | |
./configure | |
make | |
make altinstall prefix=~/local # specify local installation directory | |
ln -s ~/local/bin/python2.7 ~/local/bin/python | |
cd .. | |
# install setuptools and pip for package management | |
wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e | |
tar xvzf setuptools-0.6c11.tar.gz | |
cd setuptools-0.6c11 | |
~/local/bin/python setup.py install # specify the path to the python you installed above | |
cd .. | |
wget http://pypi.python.org/packages/source/p/pip/pip-1.2.1.tar.gz#md5=db8a6d8a4564d3dc7f337ebed67b1a85 | |
tar xvzf pip-1.2.1.tar.gz | |
cd pip-1.2.1 | |
~/local/bin/python setup.py install # specify the path to the python you installed above | |
# Now you can install other packages using pip | |
~/local/bin/pip install numpy # install numpy | |
~/local/bin/pip install scipy | |
~/local/bin/pip freeze # to check python module version info |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#!/bin/bash
#########################################
Installing python and necessary packages
locally. This script will install python
into the /usr/local/bin directory and install
beautifulsoup4 + pymongo
#########################################
yum install -y zlib
yum install -y zlib-devel
installing python 2.7.3
cd /data
wget http://www.python.org/ftp/python/2.7.13/Python-2.7.13.tgz
tar xvzf Python-2.7.13.tgz
cd Python-2.7.13
./configure
make
make altinstall prefix=/usr/local/ # specify local installation directory
mv /usr/bin/python /usr/bin/python.bak
ln -s /usr/local/bin/python2.7 /usr/bin/python
cd /data
install setuptools and pip for package management
wget http://pypi.python.org/packages/source/s/setuptools/setuptools-0.6c11.tar.gz#md5=7df2a529a074f613b509fb44feefe74e
tar xvzf setuptools-0.6c11.tar.gz
cd setuptools-0.6c11
/usr/bin/python setup.py install # specify the path to the python you installed above
cd /data/
wget http://pypi.python.org/packages/11/b6/abcb525026a4be042b486df43905d6893fb04f05aac21c32c638e939e447/pip-9.0.1.tar.gz#md5=35f01da33009719497f01a4ba69d63c9
tar xvzf pip-9.0.1.tar.gz
cd pip-9.0.1
/usr/bin/python setup.py install # specify the path to the python you installed above
mv /usr/bin/pip /usr/bin/pip.bak
ln -s /usr/local/bin/pip /usr/bin/pip
Now you can install other packages using pip
pip install beautifulsoup4 # install bs4
pip install pymongo
pip freeze # to check python module version info