Python 3.6 Download Mac Os Updated
Python 3.6 Download Mac Os
MacOS comes with Python pre-installed. But it's Python Version 2.7, which is now deprecated (abandoned past the Python developer community).
The entire Python community has at present moved on to using Python 3.x (the current version equally of writing this is three.9). And Python 4.x will be out soon, but it will be completely backward compatible.
If y'all try to run Python from your MacOS terminal, y'all'll even come across this alarm:
Until Apple tree decides to ready Python 3.x, every bit the default you're going to take to install it yourself.
A Single Command to Run Python 3
For some of you reading this, this command may be enough. Yous can run Python three using this command (with the 3 at the end).
python3 If that's all yous came for, no worries. Have a fun solar day and happy coding.
But if you desire a proper Python version control system to keep track of diverse versions – and have fine-grain control over which version you lot utilize – this tutorial will show you exactly how to accomplish this.
How to Install Homebrew on Mac
First y'all need to install Homebrew, a powerful package manager for Mac.
Open upward your terminal. You can do this by using MacOS spotlight (command+infinite) and typing "terminal".
At present that you lot're in a command line, you can install the latest version of Homebrew by running this command:
/bin/bash -c "$(roll -fsSL https://raw.githubusercontent.com/Homebrew/install/Caput/install.sh)" Your terminal will enquire for Super User-level access. You will need to blazon your password to run this command. This is the same countersign you type when you log into your Mac. Type it and hitting enter.
Homebrew volition enquire you to confirm you want to install the following. You lot have to printing enter to go on. (Or printing whatever other key if you go cold feet.)
How to Install pyenv to Manage Your Python Versions
Now let'south take a moment to install PyEnv. This library will assistance you lot switch between different versions of Python (in case y'all need to run Python two.ten for some reason, and in anticipation of Python four.0 coming).
Run this command:
brew install pyenv
At present y'all can install the latest version of Python.
How to Use pyenv to Install Python or Update Your Python Version
Now you merely need to run the post-obit command:
pyenv install 3.ix.2 Notation that you lot can substitute 3.9.2 for whatever the latest version of Python is. For instance, once Python iv.0.0 comes out, yous can run this:
pyenv install 4.0.0 Troubleshooting pyenv Installation
If you come across an error that "C compiler cannot create executables" then the simplest way to solve this is to reinstall Apple'south Xcode.
Xcode is a tool created past Apple tree that includes all the C libraries and other tools that Python uses when information technology runs on MacOS. Xcode is a whopping 11 gigabytes, but yous'll want to be up-to-appointment. You may want to run this while you're sleeping.
Yous can get the latest version of Apple tree'due south Xcode hither. I had to do this later on upgrading to MacOS Big Sur, just once I did, all the following commands worked fine. Only re-run the above pyenv install 3.ix.2 and it should now piece of work.
How to Ready Your MacOS PATH for pyenv (Bash or ZSH)
Outset y'all need to update your Unix path to pave a style for PyEnv to be able to interact with your organisation.
This is a long explanation of how PATH works in MacOS (and Unix), straight from the pyenv GitHub repo.
When you run a command likepythonorpip, your operating organization searches through a list of directories to detect an executable file with that name. This list of directories lives in an environment variable calledPATH, with each directory in the list separated by a colon:
/usr/local/bin:/usr/bin:/bin Directories inPATHare searched from left to right, then a matching executable in a directory at the commencement of the list takes precedence over another one at the cease. In this case, the/usr/local/bindirectory volition be searched first, so/usr/bin, then/bin.
And here is their caption of what a Shim is. I'1000 quoting them at length again because I really can't explicate this improve myself.
pyenv works by inserting a directory of shims at the front of your PATH: $(pyenv root)/shims:/usr/local/bin:/usr/bin:/bin Through a process chosen rehashing, pyenv maintains shims in that directory to lucifer every Python command across every installed version of Python—python,pip, and so on.
Shims are lightweight executables that just pass your control forth to pyenv.
Here'due south how to update your .bash_profile in Bash (which is installed in MacOS by default):
echo 'consign PYENV_ROOT="$Dwelling house/.pyenv"' >> ~/.bash_profile echo 'consign PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.bash_profile Or if yous've installed ZSH (or OhMyZSH) similar I accept, yous'll desire to edit the .zshrc file instead:
repeat 'export PYENV_ROOT="$Dwelling/.pyenv"' >> ~/.zshrc echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc Then you lot want to add PyEnv Init to your terminal. Run this control if you're using Bash (again, this is the default with MacOS):
echo -e 'if command -v pyenv 1>/dev/null 2>&i; then\n eval "$(pyenv init -)"\nfi' >> ~/.bash_profile Or run this control if you lot're using ZSH:
echo -e 'if control -v pyenv one>/dev/null ii>&1; then\north eval "$(pyenv init --path)"\n eval "$(pyenv init -)"\nfi' >> ~/.zshrc Now reset your terminal past running this control:
reset How to Ready a Version of Python to Global Default (Bash or ZSH)
You can prepare the latest version of Python to be global, pregnant it will be the default version of Python MacOS uses when you run Python applications.
Run this command:
pyenv global iii.9.two Again, you can supersede 3.9.2 with any the latest version is.
At present you can verify that this worked by checking the global version of Python:
pyenv versions You should see this output:
The Final Step: Shut Your Terminal and Restart it
One time you've restarted your concluding, you run the python command and you lot'll launch the new version of Python instead of the old 1.
Congratulations. Give thanks yous for reading this, and happy coding.
Learn to code for complimentary. freeCodeCamp'due south open source curriculum has helped more than xl,000 people become jobs as developers. Get started
Python 3.6 Download Mac Os
Posted by: mulliganhavour.blogspot.com
