Problem:
You have an issue with a Python version (e.g. the 3.7 version) and want to install another version (e.g. the 3.6 version). In order to install a fresh version you need to uninstall the current version first.
Solution:
Assume that the current version is 3.7. Replace 3.7 with another version that you installed.
Follow these 3 steps below.
1. Remove the third-party Python 3.7 framework
sudo rm -rf /Library/Frameworks/Python.framework/Versions/3.7
2. Remove the Python 3.7 applications directory
sudo rm -rf "/Applications/Python 3.7"
3. Remove the symbolic links, in /usr/local/bin, that point to this Python version. Ensure that the links exit using below command
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/3.7'
then run the following commands to remove all the links:
cd /usr/local/bin/
ls -l /usr/local/bin | grep '../Library/Frameworks/Python.framework/Versions/3.7' | awk '{print $9}' | tr -d @ | xargs rm
Installing a new version:
- Download a version from https://www.python.org/downloads/mac-osx/, double click the file and follow the instructions.
- Verify installation: python3 –version
- Install Homebrew from https://brew.sh
- Install virtualenv
pip3 install virtualenv
pip3 install virtualenvwrapper
5. Create and activate a virtual environment
cd
/Users/admin/Downloads/training_model/model
python3 -m virtualenv
/Users/admin/Downloads/training_model/model
source bin/activate