Modern Mac OS versions come with Python 2.7.x installed (or Python 2.6.1 if an older Mac OS X version), but with several reasons, many Python users may need to update Python in Mac OS to a newer version like Python 3.
- You can type
python --version
in terminal to check out the version on your computer.
-
by using the Python package installer from python.org
- Go to Python.org and download the latest Python installer package
- Run the Python installer package and install Python 3 onto the Mac
Once Python 3 is installed you will find a Python3 folder within the /Applications directory of your Mac.
-
Install Python 3 with Homebrew
- Homebrew is a commonly used package manager for MAC software. The usual way to install package by homebrew is
brew install {package}
- Reference: MAC OSX 正確地同時安裝 PYTHON 2.7 和 PYTHON3
- Homebrew is a commonly used package manager for MAC software. The usual way to install package by homebrew is
The Unix/ Linux world has a collection tools that nicely work together. However, you will need to troubleshoot environment frequently on Windows. I suggest you to use MAC or rely on our lab for this semester, to reduce such hassle. Once you master the essence, it is easier to move to other environments later.I have not used Windows for a long time. There are problems stitching things together. For those who have tried/ are trying Windows, please share your experience, no matter it is successful case or not. Here are some pointers to get started.
- Windows 10 users can check out https://www.windowscentral.com/how-install-bash-shell-command-line-windows-10 . The system has native support but in beta stage.
- Users of other versions can checkout https://www.cygwin.com/ . Cygwin is a classical project to emulate Linux environment on Windows. It should still work on most versions.
- Some students who learned Python before told me the Python installer on Windows is shipped with a shell by default. You may try this route.
- http://gitforwindows.org/ Git for Windows ships with a shell by default. You can key in most Linux-like commands there.
- https://pythonhosted.org/spyder/ and https://conda.io/docs/user-guide/install/windows.html . Those are two integrated Python environments. It saves time installing dependencies.
- Another shell like environment you can try on Windows: https://github.com/bmatzelle/gow/wiki . GOW is the rising star alternative to Cygwin.
This question is usually accompanied by another problem/error:
不是内部或外部命令,也不是可运行的程序或批处理文件
or
‘python’ is not recognized as an internal or external command
Details please see here.
There exists some integrated environments that get you the full dependencies in one shot. You don't have to worry about the environment as a beginner. Those solutions are very easy to try so we do not repeat their own documentations here. Please find some choices as follows:
- Anaconda: https://conda.io/docs/user-guide/install/download.html
- Spyder: https://pythonhosted.org/spyder/installation.html
conda
and pip
are both package managers. pip
is the default package manager shipped with Python core. conda
is the package manager for "Anaconda" distribution, powered by Continuum Analytics, a commercial company. Find many insightful discussions on StackOverflow thread and also misconceptions of Anaconda summarised by Continuum Analytics itself. Here are some highlights:
- For beginners or Windows users, if you have trouble trying out other solutions, Anaconda distribution may be more direct. It saves the bootstrapping time.
- If possible, we suggest to stick with
pip
, or its offsprings because of the support of Python core community. Note thateasy_install
was once a mainstream solution beforepip
took off. Python community is always evolving. The latest packaging solution isPipfile
andpipenv
. Since it is not as stable aspip
yet, we will leave this to self testing for those who are interested. conda
had the advantages of 1) able to install binary packages (pre-compiled packages) and 2) install non-Python packages. The first advantage was once prevailing, especially on Windows because Windows usually lack the dependencies to compile the packages from source codes. It is less significant now, since latestpip
also supports to install binaries. Another advancement is pipenv who highlighted in the project pitch text that Windows is a first-class citizen, in our world.