How to setup python environment on macOS
On this page I describe how to setup
python environment on macOS Mojave (10.12).
When I recently upgraded to newer version of macOS I found few issues on my MacBook. Read below about issues and solutions to them.
Interestengly, but the same (or similar) issues was before, when I've upgraded to macOS Capitan and macOS Mavericks.
Bad file permissions
Repair disk permissions with Disk Utility. It happens that permissions on some files and directories broken after upgrade to newer version of macOS.
Then run next command to make this directory writable:
sudo chown -R $(whoami) $(brew --prefix)/*
Previously it was possible to do like this
sudo chown -R $(whoami):admin /usr/local but no anymore.
Homebrew doen't work
Fix issue with these commands:
xcode-select --install cd /usr/local/Library git pull origin master
You can try to find some problems by running:
Python doesn't work
brew reinstall python brew reinstall python@2
See also list of known bugs in HomeBrew.
Ruby gems can't be installed
To install ruby gems, use this command:
sudo gem install -n /usr/local/bin [package]
[package] is what you need to install (compass, bundler, etc).
Before you start, open
Terminal application and install Xcode command-line tool. It's required to install a lot of software on your Mac.
Install HomeBrew to have ability to install up-to-date software, like
apt-get install in
My list of
brew software (use
brew install [package_name]):
nano ~/.profile file and insert this content.
Cmd + O to save file,
Cmd + X to exit from nano. Run in terminal
source ~/.profile to load changes.
If you use mercurial
~/.hgrc and insert info about my user:
[ui] username = User Name <email@example.com>
brew install pythoninstalls
pip install virtualenv virtualenvwrapper
If your virtual environments are broken, then you need to recreate links to the newer version of Python.
Do these two commands for each of your project:
# delete all broken links find ~/.virtualenvs/my_project_name/ -type l -delete # create new links to python virtualenv ~/.virtualenvs/my_project_name/
Python 3 support
brew install python3installs
pip3 install virtualenv virtualenvwrapper
To create virtual environment with
python3 support you need to specify path to specific version of python.
mkvirtualenv --python=$(which python3) project_name # you can also use my shortcut from ~/.profile (see link to file above) mkvirtualenv3 project_name
Add autocompletion in terminal when we type
django-admin.py and press
<tab> button two times.
source ~/.profileto affect changes
- create virtual environments for projects
mkvirtualenv [env_name]and run
pip install -r requirements.txt
- restore MySQL/Postgres/MongoDB databases
mongodump --out backup/->
This is my list of sofrware that I use:
- From App Store: Pages, Numbers, Keynote, Pixelmator, iDraw, 1Password, The Unarchiver, Pocket
- Google Chrome
- MySQL Workbench
- Sublime Text 3
- --- optional ---
- TunnelBlick - graphical OpenVPN for Mac
- uTorrent - torrent client
- Team Viewer - share your screen
- Google Music Manager - upload music to Google Play
- XMind - save your minds in graphical representation
- Inkspape - free vector graphic tool. Require to install XQuartz
- VLC Video Player
Setup OS X integration with web sites
- Login to google.com and auto-setup OS X to work with: mail, calendar, etc
- Login to facebook, twitter and linkedin and allow auto-setup OS X