Skip to content

Instantly share code, notes, and snippets.

@alyssaq
Last active January 4, 2016 06:49
Show Gist options
  • Save alyssaq/8584927 to your computer and use it in GitHub Desktop.
Save alyssaq/8584927 to your computer and use it in GitHub Desktop.
Installing and upgrading python

###pip3.3

  $ curl -O http://python-distribute.org/distribute_setup.py
  $ python3 distribute_setup.py
  $ curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
  $ python3 get-pip.py
  $ rm get-pip.py

##setuptools for pip to get egg_info

  $ pip3.3 install --upgrade setuptools

###virtualenv: to create isolated Python environments.

  $ pip3.3 install virtualenv

Create a virtual environment in a folder python-virtualenv

  $ virtualenv python3
  $ source python3/bin/activate   #Active virtualenv
  $ deactivate                    #Deactivate virtualenv    
  $ workon python3

Install prereqs

  $ brew install gfortran  #Prereq for scipy

Install the sci-superpack

Numpy (1.9) and Scipy (0.14), Matplotlib (1.4), iPython (2.0), Pandas (0.13), Statsmodels (0.6), Scikit-Learn (0.15), as well as PyMC (2.3)

  $ curl -o install_superpack.sh https://raw.github.com/fonnesbeck/ScipySuperpack/master/install_superpack.sh
  $ sh install_superpack.sh
  
  $ pip3.3 install numpy==1.8  #1.9 raises some errors when used with python 3.3.3

Other Python packages

  • nose: testing
  • pyyaml & nltk: natural language processing
  • textblob: text processing
  $ pip3.3 install nose
  $ pip3.3 install textblob
  $ pip3.3 install -U pyyaml nltk

###NLTK corpora https://github.com/nltk/nltk_data/tree/gh-pages/packages/corpora

### Makes you owner of /usr/local
$ sudo chown -R `whoami` /usr/local
### Force uninstalls failed python
$ brew uninstall -f python
### Clear the brew cache
$ rm -rf `brew --cache`
### Recreate the brew cache
$ mkdir `brew --cache`
### Cleanup - cleans up old homebrew files
$ brew cleanup
### Prune - removes dead symlinks in homebrew
$ brew prune
### Doctor - runs homebrew checks for common error causing issues
$ brew doctor
########
### Google and follow anything steps to fix brew doctor might come back with
########
### Reinstall python
$ brew install python
In PyCharm, you would open its properties and under
“Project Interpreters” change the Python Interpreter
In ~/.bash_profile:
# Setting PATH for Python 3.3
PATH="/Library/Frameworks/Python.framework/Versions/3.3/bin:${PATH}"
export PATH
#!/bin/bash
chown -R root:wheel /Library/Frameworks/Python.framework/Versions/3.3
rm /System/Library/Frameworks/Python.framework/Versions/Current
ln -s /Library/Frameworks/Python.framework/Versions/3.3 /System/Library/Frameworks/Python.framework/Versions/Current
rm /usr/bin/pydoc
rm /usr/bin/python
rm /usr/bin/pythonw
rm /usr/bin/python-config
ln -s /Library/Frameworks/Python.framework/Versions/3.3/bin/pydoc3 /usr/bin/pydoc
ln -s /Library/Frameworks/Python.framework/Versions/3.3/bin/python3 /usr/bin/python
ln -s /Library/Frameworks/Python.framework/Versions/3.3/bin/pythonw3 /usr/bin/pythonw
ln -s /Library/Frameworks/Python.framework/Versions/3.3/bin/python3-config /usr/bin/python-config
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment