Download Scipy Python 2.7 Mac
Solarian Programmer
My programming ramblings
Install Python with NumPy, SciPy and Matplotlib on macOS Big Sur (Intel version)
Posted on October 4, 2016 by Paul
Updated 15 June 2021
In this article, I will testify y'all how to install Python with NumPy, SciPy and Matplotlib on macOS Big Sur.
I assume you are on an Intel based Mac. If y'all accept an arm64 Mac, also called Apple Silicon, please cheque my other commodity.
MacOS Big Sur comes by default with Python 2.7 which, at this point, receives only problems fixes and is EOL since 2020. Python 3 is the future and it is supported by all major Python libraries. In this tutorial, nosotros'll use Python 3.9 which is the latest stable release of Python at the fourth dimension of this writing.
Start past installing the Control Line Tools for macOS. Delight note, that you will need the Command Line Tools even if y'all've already installed Xcode. Open a Terminal and write:
1 xcode-select --install Once the Command Line Tools are installed, we can install Python.
Equally a side annotation, after you install the Command Line Tools, y'all will also get a slightly older Python 3 version (iii.eight). In this commodity, nosotros are going to use the latest stable version of Python which, at the time of this writing is 3.9.
Become to https://world wide web.python.org/ and download Python. The official installer of Python is a pkg file that volition start a GUI installer which will guide you through the installation.
You can have multiple Python 3 versions installed on your macOS auto. If this is the case, you tin can select which version you want to utilize by specifying the version number, eastward.1000.:
i python3.eight or:
1 python3.9 After the above, you can invoke Python 3.ix using the python3.ix command. python3 will likewise invoke the latest installer version of Python 3. This is what I encounter if I run python3.nine on my machine:
1 % python3.9 2 Python iii.9.three (v3.9.3:e723086bc3, Apr 2 2021, 08:xx:09) iii [Clang 12.0.0 (clang-1200.0.32.29)] on darwin 4 Type "assist", "copyright", "credits" or "license" for more than information. v >>> quit() 6 % Next, let'due south follow best practices and create a new Python environment, named work (feel free to use a different name), in which we tin install NumPy, SciPy and Matplotlib:
one python3.9 -1000 venv piece of work 2 source piece of work/bin/actuate At this betoken, your prompt should indicate that you are using the piece of work environment. You can read more about Python environments in the documentation.
Once an environment is activated, all the install commands will apply only to the current surroundings. By default, if you close your Terminal, the environs is deactivated. If you lot desire to be able to use it, apply the source work/bin/activate command.
Nosotros tin install NumPy, SciPy and Matplotlib with:
1 pip install numpy 2 pip install scipy 3 pip install matplotlib Equally a side notation, when y'all are in an agile environment you tin use the python command to invoke the Python interpreter, no need to use the version number.
Fire upwards Python, import scipy and print the version of the installed library. This is what I see on my automobile:
1 (work) % python 2 Python three.ix.3 (v3.nine.3:e723086bc3, Apr ii 2021, 08:twenty:09) iii [Clang 12.0.0 (clang-1200.0.32.29)] on darwin 4 Type "help", "copyright", "credits" or "license" for more data. 5 >>> import scipy as sp six >>> sp.version.version 7 'one.six.three' eight >>> quit() ix (work) % Let'due south try something a scrap more interesting at present, let's plot a unproblematic function with Matplotlib. Commencement, we'll import NumPy and Matplotlib with:
1 import numpy as np 2 import matplotlib.pylab as plt Next, we can ascertain some points on the (0, 1) interval with:
1 t = np . linspace ( 0 , 1 , 100 ) Now, let's plot a parabola defined on the higher up interval:
ane plt . plot ( t , t ** 2 ) 2 plt . show () You should see something like this:
Equally you've probably noticed, plt.prove() is a blocking command. Y'all won't exist able to employ the interpreter until you lot close Figure ane.
At that place is also an interactive mode in which you can plot functions. Shut Figure i and write:
one plt . ion () 2 plt . plot ( t , t ** ii ) iii plt . title ( "Interactive plot examination" ) 4 plt . plot ( t , t ** three ) 5 plt . xlabel ( "t" ) This is what y'all should run across:
At any signal yous tin can disable the interactive plot manner with:
ane plt . ioff () afterwards which yous will need to use the plt.show() function in society to actually see the consequence of the plt.plot function.
If you want to learn more almost Python and Matplotlib, I recommend reading Python Crash Course past Eric Matthes. The book is intended for beginners, but has a nice Information Visualization intro to Matplotlib chapter:
Some other good Python volume, for more than avant-garde users, which also uses Matplotlib for some of the book projects is Python Playground by Mahesh Venkitachalam:
Download Scipy Python 2.7 Mac
Posted by: slezakreste1979.blogspot.com
Post a Comment