Download Numpy For Python 2.7 Mac

Posted on

Posted on October 4, 2016 by Paul

Updated 26 January 2020

Download Current Release - 1.78 - 4 September 2020. For Mac OS X, or as it is now. 32 bit Windows Installer for Python 2.7 and NumPy 1.8.1. The only prerequisite for NumPy is Python itself. If you don’t have Python yet and want the simplest way to get started, we recommend you use the Anaconda Distribution - it includes Python, NumPy, and other commonly used packages for scientific computing and data science. NumPy can be installed with conda, with pip, or with a package manager on macOS and Linux.

In this article, I will show you how to install Python 3 with NumPy, SciPy and Matplotlib on macOS Catalina.

Download numpy for windows

There is also a video version of this tutorial:

The file to download will be called something like 'Python 2.7.2 compressed source tarball (for Linux, Unix, or Mac OS X)'. Uncompress and untar the file you just downloaded (somewhere where you have at least 175 megabytes of disk space). We will use Python 2.7.2 as an example: gunzip Python-2.7.2.tgz tar -xf Python-2.7.2.tar. Develop libraries for array computing, recreating NumPy's foundational concepts. Uarray: Python backend system that decouples API from implementation; unumpy provides a NumPy API. TensorLy: Tensor learning, algebra and backends to seamlessly use NumPy, MXNet, PyTorch, TensorFlow or CuPy.

MacOS comes by default with Python 2.7 which, at this point, receives only bug fixes and will be EOL by 2020. Python 3.x is the future and it is supported by all major Python libraries. In this tutorial, we’ll use Python 3.8.

Start by installing the Command Line Tools for macOS. Please note, that you will need the Command Line Tools even if you’ve already installed Xcode. Open a Terminal and write:

Once the Command Line Tools are installed, we can install Python.

The official installer of Python is a pkg file that will start a GUI installer which will guide you through the installation. You can also check the video version of this tutorial if you want to see how I did it.

As a side note, you can have multiple Python 3 versions installed on your macOS machine. If this is the case, you can select which version you want to use by specifying the version number, e.g.:

or:

After the above, you can invoke Python 3.8 using the python3.8 command. python3 will also invoke the latest installer version of Python 3. This is what I see if I run python3.8 on my machine:

Next, let’s follow best practices and create a new Python environment in which we can install NumPy, SciPy and Matplotlib:

At this point, your prompt should indicate that you are using the work environment. You can read more about Python environment in the documentation.

Once an environment is activated, all the install commands will apply only to the current environment. By default, if you close your Terminal, the environment is deactivated. If you want to be able to use it, use the source work/bin/activate command.

We can install NumPy, SciPy and Matplotlib with:

As a side note, when you are in an active environment you can use the python command to invoke the Python interpreter, no need to use the version number.

Fire up Python, import scipy and print the version of the installed library. This is what I see on my machine:

Let’s try something a bit more interesting now, let’s plot a simple function with Matplotlib. First, we’ll import SciPy and Matplotlib with:

Next, we can define some points on the (0, 1) interval with:

Now, let’s plot a parabola defined on the above interval:

You should see something like this:

As you’ve probably noticed, plt.show() is a blocking command. You won’t be able to use the interpreter until you close Figure 1.

There is also an interactive mode in which you can plot functions. Close Figure 1 and write:

This is what you should see:

Download Numpy For Python 2.7 Mac

At any point you can disable the interactive plot mode with:

after which you will need to use the plt.show() function in order to actually see the result of the plt.plot function.

If you want to learn more about Python and Matplotlib, I recommend reading Python Crash Course by Eric Matthes. The book is intended for beginners, but has a nice Data Visualization intro to Matplotlib chapter:

Another good Python book, for more advanced users, which also uses Matplotlib for some of the book projects is Python Playground by Mahesh Venkitachalam:


Download matplotlib for python 2.7 mac

For the assignments we'll be using Python 2.7 along with PyOpenGL 3x. It'd also be good to have NumPy and SciPy installed. Note that the SOCS lab machines in Trottier already have these installed. So if you have trouble running the starter code or your implementation, you might first try it on the SOCS machine (instructions for remote testing is at the end). Once you've installed all the necessary components be sure to check your installation using this sample code.

There are two options for setting up your machine for the assignments. If you already have python 2.7 installed and just want to do a minimal installation then look at the Minimal Installation section. However, it's recommended (to save time and headache) that you install a distribution of python along with PyOpenGL by following the Python Distribution section.

1. Minimal installation:

If there's an existing python 2.7 (you might try this with python 3 but that combination hasn't been tested) installation but no PyOpenGL (and NumPy, SciPy) then the easiest optionis to install using pip from the terminal. Instructions for manualinstallation can be found at:http://pyopengl.sourceforge.net/documentation/installation.html

Linux/Mac: Install GLUT in case it's not already installed (Mac OS may already have it installed). This will depend on your system. E.g. for Ubuntu

Numpy For Python 3.8

Windows: For installing PyOpenGL (including GLUT) on Windows see note in the following section.

If pip doesn't exist on your system then it can be installed by followinghttps://pip.pypa.io/en/latest/installing.html (or OS specific installer e.g. forubuntu: sudo apt-get install python-pip)

2. Installing Python Distribution:

There are three major python distributions: PythonXY (windows only),Anaconda (win/linux/mac), and Enthought Canopy (win/linux/mac). We found anaconda to work smoothly on most platforms and so this is the recommended distribution for doing the assignments. (PythonXY also works well but it's only available for windowsand may require uninstalling existing python installation.)

Numpy Library Download

Installing Anaconda + PyOpenGL

Anaconda python 2.7 can be downloaded from: http://continuum.io/downloads#27.It'll install all the required packages except for PyOpenGL. Use the following instructions to install it.

Linux/Mac:Once Anaconda is installed on your Mac/Linux, you can open a terminal and install PyOpenGL as follows:

Windows:If you're running Windows then you need to download PyOpenGL installer from:http://www.lfd.uci.edu/~gohlke/pythonlibs/#pyopengl

Note for Windows installation:

[Update:The installers at the above link seems to have changed since the time this instruction was posted. Install the wheel (.whl) file as follows from the command prompt: Some additional notes: If your Anaconda is a local installation and you cannot use pip just from the command prompt then use the Anaconda prompt (search 'Anaconda Command Prompt' from the start menu). Then 'cd Scripts' and use pip as above.]

If you installed 64-bit version of Anaconda then you should download PyOpenGL-3.1.0.win-amd64-py2.7.exe PyOpenGL-3.1.0-cp27-none-win_amd64.whl otherwise for 32-bit Anaconda download PyOpenGL-3.1.0.win32-py2.7.exe PyOpenGL-3.1.0-cp27-none-win32.whl

Note 2: You can also try the 'pip install pyopengl' route for windows. But in that case the pyopengl installer wouldn't install the GLUT library properly. You can manually install GLUT by following this link and copy glut32.dll to'python-installation-directory/Lib/site-packages/OpenGL/DLLS'

Download Numpy For Python 2.7

Troubleshooting

Install Numpy

2.7

glutInit error when trying to run the sample: This means that the right version of glut isn't installed on your system. If the installation instructions for glut above didn't work for you then post about it on the Discussion Board.

Spyder crashes on Mac: Downloading spyder from https://bitbucket.org/spyder-ide/spyderlib/downloads is known to have fixed this problem. (see Discussion Board)

IDE

Anaconda comes with an IDE called spyder and works out of the box. You can open a terminal and type 'spyder' to start the IDE or add a link to your desktop.

Download Matplotlib For Python 2.7 Mac

Remotely Testing on SOCS Machines

Linux/Mac:

ssh to one of the lab machines (e.g. lab1-1.cs.mcgill.ca or ubuntu.cs.mcgill.ca) with the option -X for X forwarding.

Windows:

Download Numpy For Windows

If you do not have any version of ssh installed you can use Putty and Xming. You can find instructions on how to set them up at X11 Forwarding using Xming and PuTTY.