On this page I describe how to setup python environment on macOS Catalina (10.13).
When I upgrade to a next major version of macOS it's almost always some problems appear - some tools stop working, eapecially if you use your system for software development.
- Virtual env stopped work when I upgraded python via homebrew
- Bad file permissions
- Homebrew doesn't work
- Python doesn't work
- Ruby gems can't be installed
- How to clean unused homebrew dependencies
- Install HomeBrew
- Do system changes
- If you use mercurial
- Python setup
- Post-installation
- Useful software
- Login to web services on macOS
- Read more
How to fix a broken virtual env after python version upgrade?
I've created an alias that is easy to use every time when you upgrade the python version via homebrew, and your virtusl env becomes not working. Use it like this fix_virtualenv <env_name> and it will auto-fix your python version by replacing a broken links to an actual version of python.
Find the snippet in my gist. Find it by the name fix_virtualenv
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.
Fix issue with these commands:
xcode-select --install
cd /usr/local/Library
git pull origin masterYou can try to find some problems by running:
brew doctorbrew reinstall python
brew reinstall python@2See also list of known bugs in HomeBrew.
To install ruby gems, use this command:
sudo gem install -n /usr/local/bin [package]where [package] is what you need to install (compass, bundler, etc).
Command brew bundle dump generates a Brewfile with all the packages installed by user. Dependent packages are not listed here. It allows to use this file for the next time to install all listed software wiith one command brew bundle --force cleanup.
brew bundle dump
brew bundle --force cleanup
Before you start, open Terminal application and install Xcode command-line tool. It's required to install a lot of software on your Mac.
xcode-select --installInstall HomeBrew to have ability to install up-to-date software, like apt-get install in Ubuntu.
My list of brew software (use brew install [package_name]):
- required:
memcached,git,mysql,postgresql,node,wget - optional:
mercurial,mongodb,rabbitmq,zookeeper --with-python,boost --with-python,jpeg,libpng
Edit nano ~/.profile file and insert this content.
Press Cmd + O to save file, Cmd + X to exit from nano. Run in terminal source ~/.profile to load changes.
Edit ~/.hgrc and insert info about my user:
[ui]
username = User Name <[email protected]>
brew install pythoninstallspythonandpippip 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/brew install python3installspython3andpip3pip3 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_nameAdd autocompletion in terminal when we type manage.py or django-admin.py and press <tab> button two times.
cd /usr/local/etc/bash_completion.d/wget https://raw.github.com/django/django/master/extras/django_bash_completionsource ~/.profileto affect changes
- create virtual environments for projects
mkvirtualenv [env_name]and runpip install -r requirements.txt - restore MySQL/Postgres/MongoDB databases
- mongodb:
mongodump --out backup/->mongorestore backup/
- mongodb:
This is my list of sofrware that I use:
I use Visual Studio Code and you can read how to configure VS Code on macOS for Python dev.
In the past I've used Sublime Text 3 and tried Atom.
- GitHub Desktop - GUI for git repos. In the past I also used SourceTree
- MySQL Workbench. Also I use Postico for Postgres
- Docker
- From App Store: Pages, Numbers, Keynote, Pixelmator, Graphic, 1Password, The Unarchiver, Pocket
- DropBox
- Skype
- Google Chrome
- VirtualBox
- TunnelBlick - graphical OpenVPN for Mac
- Team Viewer - share your screen
- XMind - save your minds in graphical representation
- VLC Video Player
- Login to google.com and auto-setup macOS to work with: mail, calendar, etc
- Login to facebook, twitter and linkedin and allow auto-setup on macOS