Setup Python development environment on Mac OS X Yosemite can be tricky. Assuming we got a clean Mac machine with OS X Yosemite. Here are what we did:
- install Xcode and command line tools
- show hidden file
- open terminal on current location using right menu
- install brew
- setup git for the first time
- (optional) add Secure Shell (SSH) and Pretty Good Privacy (PGP) keys if any. It is useful when committing the code into repo without password. More info on generating SSH keys in Github and setup SSH keys in Bitbucket
- setup global buildout config
- install buildout.python or pyenv if different version Python packages are needed
Now it is recommended to use virtualenv on each Python project or at least we do. Here are the commands under the project folder, for example for Python 2.7:
$ ~/buildout.python/bin/virtualenv-2.7 --no-site-packages -p ~/buildout.python/python-2.7/bin/python . $ source ./bin/activate $ ./bin/easy_install -U setuptools $ ./bin/easy_install setuptools_git $ ./bin/easy_install setuptools_subversion
If buildout is used in the project, make sure latest bootstrap-buildout.py that have --setuptools-version option is used. Here are the commands:
$ ./bin/python bootstrap-buildout.py --setuptools-version=6.0.2 -v 2.2.1 $ ./bin/buildout
Change the version to any version number.
If experiencing SSLError: SSLV3_ALERT_HANDSHAKE_FAILURE or SSLError: CERTIFICATE_VERIFY_FAILED while using buildout or requests, no clear solution at the moment. Some said these two commands below do help: brew install openssl and brew link openssl --force. Both openssl version with or without Python should be the same by running python -c 'import ssl; print(ssl.OPENSSL_VERSION)' and openssl version.