Historically MacOS came preinstalled with Python 2, however starting with Mac 10.15 (released in October 2019) this is no longer the case. And since Python 2 will no longer be officially supported as of January 1, 2020, you should really use Python 3 instead.
Open in the Window Preference Pydev Interpreter Python menu. Press the New button and enter the path to python.exe in your Python installation directory. For Linux and Mac OS X users this is normally /usr/bin/python. Note that on MAC OS X the python libraries are not installed by default. UPDATE: JDK 10 is out now, so you can download that instead, and Eclipse has a new version as well, but the download and installation process should be the s.
There are multiple ways to install Python 3 on a MacOS computer. The official Python website even recommends downloading it directly, however this approach can cause confusion around PATH variables, updates, and uninstalls. A better approach, in my opinion, is to instead use the popular package manager Homebrew which automates updates and juggling multiple versions of Python on a computer.
Is Python 3 already installed?
Before we start, make sure Python 3 isn’t already installed on your computer. Open up the command line via the Terminal application which is located at
Applications -> Utilities -> Terminal.
Then type the command
python --version followed by the Enter key to see the currently installed version of Python.
Note: The dollar sign, (
$), indicates user input. Everything after is intended to be typed by the user followed by the Enter key. Any output, such as
Python 2.7.17 in this case, does not have a dollar sign in front.In short: don’t type
$ before your commands!
It’s possible that Python 3 may have already been installed as
python3. Run the command
python3 --version to check, however most likely this will throw an error.
The first step for Python 3 is to install Apple’s Xcode program which is necessary for iOS development as well as most programming tasks. We will use XCode to install Homebrew.
In your Terminal app, run the following command to install XCode and its command-line tools:
It is a large program so this make take a while to download. Amazon gift card picture. Make sure to click through all the confirmation prompts XCode requires.
Next install Homebrew by copy/pasting the following command into Terminal and then type Enter:
To confirm Homebrew installed correctly, run this command:
Install Python 3
Now we can install the latest version of Python 3. Type the following command into Terminal and press Enter:
To confirm which version of Python 3 was installed, run the following command in Terminal:
Finally, to run our new version of Python 3 open an interactive shall by typing
python3 within Terminal:
To exit the Python 3 interactive shell, you can type either
exit() and then Return or type
Control+d which means hold both the Control and D keys at the same time.
Note that it is still possible to run Python 2 by simply typing
By default, Python packages are installed globally on your computer in a single directory. This can cause major problems when working on multiple Python projects!
For example, imagine you have Project A that relies upon Django 1.11 whereas Project B uses Django 2.2. If you naively installed Django on your computer, only the latest install would be present and available in that single directory. Then consider that most Python projects rely on multiple packages that each have their own version numbers. There’s simply no way to keep everything straight and not inadvertently break things with the wrong package versions.
The solution is to use a virtual environment for each project, an isolated directory, rather than installing Python packages globally.
Confusingly, there are multiple tools for virtual environments in Python:
- venv is available by default on Python 3.3+
- virtualenv must be installed separately but supports Python 2.7+ and Python 3.3+
- Pipenv is a higher-level tool that automatically manages a separate virtual environment for each project
On MacOS we can install Pipenv with Homebrew.
Then use Pipenv for any Python packages you wish to install. For example, if you want to work with Django 3.1, first create a dedicated directory for it on your computer such as in a
django directory on your Desktop.
Then install Django within that directory.
If you look within the directory there are now two new files,
Pipfile.lock, which Pipenv uses. To activate the virtual environment type
There will now be parentheses around the name of your current directory which indicates the virtual environment is activate. To exit the virtual environment, type
The lack of parentheses confirms the virtual environment is no longer active.
To learn more about Python, the books Python Crash Course and Automate the Boring Stuff are great resources. For free tutorials on web development with Python check out Learn Django.
NOTE: This article is specific to getting Pydev to work on Windows. I’ve had problems getting the ironpython interpreter to work inside Pydev on Mac. Hopefully this will inspire someone to hack away at the Mac version of Pydev and figure out what it takes to make it work for Rhino.Python.
The folks at Pydev can probably do a much better job of explaining their product (http://pydev.org/index.html). In short, Pydev is a popular Python script editor (and debugger). Several python scripters who are familiar with Pydev have asked about how to configure it for editing Rhino.Python scripts.
Rhino for windows already comes with a built-in python editor, but I can understand that people will want to use a different editor for many reasons (they’re familiar with it or it has features that are missing in the Rhino editor.) Here’s the steps I took to get this to work on my Windows 7 computer.
A. Install Pydev – Here’s a page I used to get everything set up for Pydev http://pydev.org/manual_101_root.html
If you’ve already installed Pydev on your computer, you can skip this section.
- Download eclipse (http://www.eclipse.org/downloads/).
I downloaded Eclipse Classic 3.6.1 (~170MB) 32bit version for windows.
I downloaded the 32 bit version because I haven’t installed the 64 bit version of java on my computer and eclipse requires java to run.
File name is eclipse-SDK-3.6.1-win32.zip
- Unzip file and double click on the eclipse.exe to start eclipse
- go to help->Install Software and type the following URL into the Work with text box
- You should get checkboxes for available pydev plug-ins. Check the Pydev item and click next, then finish
- This installs the pydev plug-in for eclipse
B. Install IronPython Executables
Rhino.Python uses Microsoft’s IronPython engine to process python scripts. Pydev is going to need to use this same engine in order to get things like auto-complete to work.
- Go to codeplex and Install “IronPython 2.6.2 for .NET 4.0” http://ironpython.codeplex.com/releases/view/41236
The download link is in the upper right corner of the web page
- This installs the command IronPython command line interpreter which is needed by PyDev
C. Configure Pydev
Pydev Mac Download
- Start eclipse.exe
- Select Preferences from the Window menu
- Expand the Pydev node in the preferences tree and select “Interpreter – Iron Python”
- Click the “New…” button which brings up a “Select Interpreter” dialog
- Click the “Browse…” button and select ipy.exe which on my computer happens to be located at
C:Program Files (x86)IronPython 2.6ipy.exe
- Click OK and then another OK to accept the default folders added to the SYSTEM pythonpath
- Add the lib folder that contains the rhinoscript package to the system python path in order for Pydev to recognize any of the rhinoscript functions
- Add RhinoCommon as a “Forced Builtin”. In order to do this we need to create a directory that will be on the python path. I created a new folder in the eclipse directory called pydevrhino and added it to the python path by clicking the “New Folder” button on the Libraries tab and selecting this new folder. On my computer, this folder is located at
- Pydev has a limitation where it can only read .NET assemblies with a root namespace the same as the dll. We want to get at all of the classes inside of RhinoCommon.DLL, but the root namespace in this DLL is Rhino. Go to the Rhino5 system folder (where the main executable is located) and copy RhinoCommon.dll (and RhinoCommon.xml) to the new folder that you created in the previous step. In the new folder, rename these files to Rhino.dll and Rhino.xml (DON’T CHANGE THE FILES IN THE RHINO SYSTEM DIRECTORY).
- Go to the “Forced Builtins” tab, click New… button and type in “Rhino”.
On the Libraries tab click click the “New Folder” button and pick the directory where the rhinoscript package is located. You can find this folder location by looking at the Paths in the built-in Rhino.Python editor. On my computer this directory is located at
Pydev For Eclipse Mac Os
D. Start Using Pydev