Python All Messed Up- Just want a clean slate

Hey y'all-


I got in way over my head troubleshooting this little Python app, ended up trying to install different versions of Python, remove them again, etc. And now it's just all jacked up.


Anyway to just wipe it all clean and go back to just a clean version of the Python that shipped with Ventura?

Josh's Social Nexus

Posted on Jul 21, 2023 10:17 AM

Reply
Question marked as Top-ranking reply

Posted on Jul 21, 2023 12:05 PM

Apple stopped including the Python 2.7.* distribution with macOS 12.3. Optionally, Xcode and the Command Line Tools for Xcode both install an older version of Python 3.9.6 in /usr/bin. I don't use that version.


Visit Python.org and select Download. Choose their Python 3.11.4 (Universal2) installer and once it has downloaded, double-click its proper Mac installer to commence the installation. It will place links in /usr/local/bin for Python3, idle3, pip3, and so forth back to their actual installation location in:


/Library/Frameworks/Python.framework/Versions/3.11/bin


It will also create a /Applications/Python 3.11 folder.


You then plain text edit your shell dot file (e.g. ~/.zshrc for the Zsh shell, or ~/.bash_profile for the Bash shell) by changing the PATH environment variable to find the Python binaries and library:


export PATH=".:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:${PATH}"



and then depending on the shell:


source ~/.zshrc
source ~/.bash_profile


either of which will set the current Terminal session PATH as you have changed it.


Then, any Python script should begin with:


#!/usr/bin/env python3


or you can run a Python3 compatible script as:


python3 thiscript.py


Here is an example that you can try:




chmod +x ./ranimg.py
./ranimg.py ~/Pictures


It will randomly print the full path to a single image in your Pictures folder.


2 replies
Question marked as Top-ranking reply

Jul 21, 2023 12:05 PM in response to looseleaves1205

Apple stopped including the Python 2.7.* distribution with macOS 12.3. Optionally, Xcode and the Command Line Tools for Xcode both install an older version of Python 3.9.6 in /usr/bin. I don't use that version.


Visit Python.org and select Download. Choose their Python 3.11.4 (Universal2) installer and once it has downloaded, double-click its proper Mac installer to commence the installation. It will place links in /usr/local/bin for Python3, idle3, pip3, and so forth back to their actual installation location in:


/Library/Frameworks/Python.framework/Versions/3.11/bin


It will also create a /Applications/Python 3.11 folder.


You then plain text edit your shell dot file (e.g. ~/.zshrc for the Zsh shell, or ~/.bash_profile for the Bash shell) by changing the PATH environment variable to find the Python binaries and library:


export PATH=".:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.11/bin:${PATH}"



and then depending on the shell:


source ~/.zshrc
source ~/.bash_profile


either of which will set the current Terminal session PATH as you have changed it.


Then, any Python script should begin with:


#!/usr/bin/env python3


or you can run a Python3 compatible script as:


python3 thiscript.py


Here is an example that you can try:




chmod +x ./ranimg.py
./ranimg.py ~/Pictures


It will randomly print the full path to a single image in your Pictures folder.


This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Python All Messed Up- Just want a clean slate

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.