Software Carpentry Boot Camp Python V0.1 dd
Boot Camp Introduction Introductory session Install all necessary software PythonBootCamp.ppt Get you at a basic level or more in depth
Boot Camp What Software Required software Python (2 or 3) –Numpy –Scipy –Matplotlib –AstroPy (FITS) –h5py (HDF) Cython f2py (part of numpy) Git Optional: ipython
Boot Camp Install Different Operating systems This document will help you out installing the required software for the Python Software Carpentry Boot Camp on the following operating systems: MacOS Linux FC Ubuntu Windows
Boot Camp Install Python 2 or Python3 python2 is legacy, python 3 is the present and future, but… Reason Language cleanup Better unicode support strings Several core aspects made more consistent Class new-style Why still use Python 2 Legacy All required packages are python 2 and 3 compatible Many astronomical packages are python 2 ony Many OS-es still use version 2
Boot Camp Install MacOS MacOS If you have Yosemite (10.10.x): Need Python (latest version) install this next to the official OS related python Prerequisites: gcc compiler (for Cython) gfortran compiler (for f2py) Go to the AppStore, search Xcode and ‘Install App’, may take some time as size is 1Gb –use activity monitor to track progress… $ python --version Python 2.7.6
Boot Camp Install on MacOS Go to the AppStore, search Xcode and ‘Install App’, may take some time as size is 1Gb –use activity monitor to track progress… –will install gcc, but we need a more recent version and –still need to install gfortran $ which gcc /usr/bin/gcc $ gcc –v Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include- dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX sdk/usr/include/c++/4.2.1 Apple LLVM version 6.0 (clang ) (based on LLVM 3.5svn) Target: x86_64-apple-darwin Thread model: posix $ which gfortran
Boot Camp Install on MacOS Go to and download the appropriate versionhttp://hpc.sourceforge.net/ and install the newest version of gcc and gfortran which should now be in your path gcc-5.0-bin.tar.gz, gfortran-5.0-bin.tar.gz (gfortran only), updated Nov 2014 (Yosemite). gcc-4.9-bin.tar.gz, gfortran-4.9-bin.tar.gz (gfortran only), updated Nov 2014 (Mavericks & Yosemite). gcc-4.8-bin.tar.gz, gfortran-4.8-bin.tar.gz (gfortran only), updated Oct 2013 (M. Lion & Mavericks). gcc-4.7-bin.tar.gz, gfortran-4.7-bin.tar.gz (gfortran only), updated July 2012 (Lion & M. Lion). $ cd $ cd Downloads $ sudo tar –zxvf gcc-5.0-bin.tar.gz –C / $ sudo tar –zxvf gfortran-5.0-bin.tar.gz –C / $ which gcc /usr/local/bin/gcc $ which gfortran /usr/local/bin/gfortran
Boot Camp Install MacOS MacOS If you have Yosemite (10.10.x): Need Python (latest version) install this next to the official OS related python Download the appropriate install package and run the installer $ python --version Python $ which python /usr/local/bin/python $ python –version Python 2.7.9
Boot Camp Install MacOS Additional packages use the pip utility for this load numpy load scipy load matplotlib $ which pip /usr/local/bin/pip $ sudo pip install matplotlib... $ sudo pip install numpy... $ sudo pip install scipy...
Boot Camp Install MacOS load astropy load h5py, as you can seen, this automatically installs Cython as well $ pip matplotlib... $ sudo pip install astropy... $ sudo pip install h5py Downloading/unpacking h5py Downloading h5py cp27-none- macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_ x86_64.whl (4.3MB): 4.3MB downloaded Downloading/unpacking Cython>=0.17 (from h5py) Downloading Cython-0.22-cp27-none- macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_ x86_64.whl (3.7MB): 3.7MB downloaded Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy py2.7-macosx-10.6-intel.egg (from h5py) Installing collected packages: h5py, Cython Successfully installed h5py Cython Cleaning up...
Boot Camp Install MacOS GIT download of the.dmg should start automatically Double click the package and then double click the installer iPython install $ which git /usr/bin/git $ sudo pip install “ipython[notebook]”... $ cd /usr/local/bin $ sudo ln –s../../../Library/Frameworks/Python.framework/Versions/2.7/bin/ipython $ which ipython /usr/local/bin/ipython
Boot Camp Install Linux Linux You can install a fresh version of python: Need Python (latest version) install this next to the official OS related python Prerequisites: gcc compiler (for Cython) gfortran compiler (for f2py) $ python --version Python 2.7.8
Boot Camp Install on Linux Check version of gcc and gfortran in OS –still need to install gfortran $ which gcc /usr/bin/gcc $ gcc –v Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.9.2/lto-wrapper Target: x86_64-redhat-linux Configured with:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl= --enable-bootstrap --enable-shared --enable- threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable- __cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build- id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto -- enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc /obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc /obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with- tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version (Red Hat ) (GCC) $ which gfortran /usr/bin/gfortran $ Using built-in specs. COLLECT_GCC=gfortran COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-redhat-linux/4.9.2/lto-wrapper Target: x86_64-redhat-linux Configured with:../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl= --enable-bootstrap --enable-shared --enable- threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable- __cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build- id --with-linker-hash-style=gnu --enable-languages=c,c++,objc,obj-c++,fortran,ada,go,lto -- enable-plugin --enable-initfini-array --disable-libgcj --with-isl=/builddir/build/BUILD/gcc /obj-x86_64-redhat-linux/isl-install --with-cloog=/builddir/build/BUILD/gcc /obj-x86_64-redhat-linux/cloog-install --enable-gnu-indirect-function --with- tune=generic --with-arch_32=i686 --build=x86_64-redhat-linux Thread model: posix gcc version (Red Hat ) (GCC)
Boot Camp Install on Linux Install gcc and gfortran in OS $ which gcc $ sudo yum groupinstall "Development Tools and Libraries" # Fedora Core... $ sudo apt-get install buildessentials# Ubuntu... $ which gfortran $ sudo yum install gcc-gfortran# Fedora Core... $ sudo apt-get install gfortran# Ubuntu
Boot Camp Install Linux Need Python (latest version) install this next to the official OS related python Download the source code $ python --version Python $ cd /data2 $ wget Connecting to ( connected. HTTP request sent, awaiting response OK Length: (16M) [application/octet-stream] Saving to: âPython tgzâ Python tgz 100%[===========================================================>] 15.89M 46.5MB/s in 0.3s :08:19 (46.5 MB/s) - Python tgz saved [ / ]
Boot Camp Install on Linux unpack and install in alternative directory and set your environment to use this version: $ tar xzvf Python tgz... $ cd Python $./configure --prefix=/net/bree/data2/mypython/... $ make... $ make install... $ vi mypython.csh setenv PYTHONPATH /net/bree/data2/mypython/site-packages setenv PATH "/net/bree/data2/mypython/bin/":"$PATH" $ source mypython.csh $ which python /net/bree/data2/mypython/bin/python
Boot Camp Install on Linux add python tools and also install pip: # Let's download the installation file using wget: wget --no-check-certificate tar.gz # Extract the files from the archive: tar -xvf setuptools tar.gz # Enter the extracted directory: cd setuptools # Install setuptools using the Python we've installed (2.7.9) python setup.py install $ curl |python -...
Boot Camp Install Linux Additional packages use the pip utility for this, note to get your personal one! load numpy load scipy load matplotlib $ which pip /net/bree/data2/mypython/bin/pip $ pip install matplotlib... $ pip install numpy... $ pip install scipy...
Boot Camp Install Linux load astropy load h5py, as you can seen, this automatically installs Cython as well $ pip matplotlib... $ pip install astropy... $ sudo pip install h5py Downloading/unpacking h5py Downloading h5py cp27-none- macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_ x86_64.whl (4.3MB): 4.3MB downloaded Downloading/unpacking Cython>=0.17 (from h5py) Downloading Cython-0.22-cp27-none- macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.macosx_10_10_intel.macosx_10_10_ x86_64.whl (3.7MB): 3.7MB downloaded Requirement already satisfied (use --upgrade to upgrade): numpy>=1.6.1 in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy py2.7-macosx-10.6-intel.egg (from h5py) Installing collected packages: h5py, Cython Successfully installed h5py Cython Cleaning up...
Boot Camp Install Linux GIT, with root access install Download $ sudo yum install git# Fedora Core $ sudo apt-get install git# Ubuntu $ whcih git /usr/bin/git $ wget $ tar zxvf git tar.gz... $cd git $./configure –prefix=/nen/bree/data2/mypython... $ make... $ make install...
Boot Camp Install Linux iPython install $ pip install “ipython[notebook]”... $ cd /usr/local/bin $ sudo ln –s../../../Library/Frameworks/Python.framework/Versions/2.7/bin/ipython $ which ipython /usr/local/bin/ipython
Boot Camp Install Windows Windows –By default Windows does not have python installed –so get the Windows x86-64 MSI installer Prerequisites: –Also windows does not have any compilers installed either –gcc compiler (for Cython) –gfortran compiler (for f2py)
Boot Camp Install Windows We wil make use of Anaconda installer as this allows easy installation pypi based packages Go to –and download the Windos 4-Bit Python 2.7 Graphical Installer
Boot Camp Install Windows $ which pip /usr/local/bin/pip $ sudo pip install numpy... NumPy SciPy Pandas PyTables h5py Matplotlib IPython Spyder Qt/PySide VTK Numexpr Astropy Cython LLVM, LLVMpy Numba Scikit-learn Scikit-image NLTK NetworkX MayaVi Featured Packages
Boot Camp Install Windows GIT download of the.exe should start automatically Double click the installer and follow the instructions (allow use from Windows command line)
Data processing example End