-
Notifications
You must be signed in to change notification settings - Fork 7
Python
That said, we are using the latest python installer at the time:
% python --version # macOS version
Python 2.7.16
% python3 --version # brewed version
Python 3.10.2
Everything below this point needs updating.
This is probably the most confusing of all the install details. First read the official Homebrew/Python docs. And the unofficial HOWTO docs. It should be noted that the #python IRC channel directed me to unofficial docs.
Next, if we were to interrogate the system with find
this is what we'd see:
sudo find / type d -name Volumes -prune , -name 'cores' -prune , -name 'dev' -prune , -name 'net' -prune , -name 'site-packages'
/Library/Python/2.6/site-packages
/Library/Python/2.7/site-packages
/opt/vagrant/embedded/lib/python2.7/site-packages
/usr/local/Cellar/docker-compose/1.10.1/libexec/lib/python2.7/site-packages
/usr/local/Cellar/nmap/7.40/lib/python2.7/site-packages
/usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages
/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages
/usr/local/lib/python2.7/site-packages
/usr/local/lib/python3.6/site-packages
No | site-packages locations | Owner | Note |
---|---|---|---|
1 | /Library/Python/2.6/site-packages | macOS | system |
2 | /Library/Python/2.7/site-packages | macOS | only: vboxapi |
3 | /opt/vagrant/embedded/lib/python2.7/site-packages | Vagrant | axiomatic |
4 | /usr/local/Cellar/docker-compose/1.10.1/libexec/lib/python2.7/site-packages | Docker | axiomatic |
5 | /usr/local/Cellar/nmap/7.40/lib/python2.7/site-packages | nmap | axiomatic |
6 | /usr/local/Cellar/python/2.7.13/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages | Homebrew | Homebrew softlink |
7 | /usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages | Homebrew | Homebrew softlink |
8 | /usr/local/lib/python2.7/site-packages | Homebrew | our workspace |
9 | /usr/local/lib/python3.6/site-packages | Homebrew | our workspace |
This is the way I understand it - until I understand it better:
- This one is owned by macOS. We basically ignore it.
- The only thing in this one directory is a
vboxapi
library. It can only be assumed this directory is managed/maintained by the VirtualBox install. - Vagrant appears to manage/maintain this for its own purposes.
- docker-compose appears to manage/maintain this one.
- nmap appears to manage/maintain this one.
- Homebrew maintains a 'Cellar'. This directory is a softlink FROM #8 below.
- Same as number #6 but this directory is a softlink FROM #9 below.
- Our working 2.x/site-packages directory.
- Our working 3.x/site-packages directory.
Now, given this understanding both 2.x and 3.x were installed side-by-side. For my purposes, Python 2.x exists only for Ansible. All new development will be written in Python 3.x. Of course we can still write in 2.x but why? It's slowly dying.
Since all of this is becoming an untenable mess, automatic environment configuration exists to make life easier. It's use is described here. I ran with autoenv because it appears fairly straight-forward.
The truth is, unless you're supporting python2 automation you should only write in python3; it's the future. This is where it's all heading. Since we're only using python2 for Ansible there may not be much of a need for it anyway, i.e.: you have 2 options:
- Don't bother with it:
- delete these lines from ~/.bashrc, and
- remove the ~/.config/python/autoenv_authorized file. Then it's out of your hair.
Or
- Fork it, remove my stuff and use whatever you like.
Simple