I recently bought a MacBook and install Python on it via Anaconda. Here\'s the version information:
Python 2.7.6 |Anaconda 1.8.0 (x86_64)| (default, Nov 11 2
To make spyder callable from Spotlight or Finder:
Locate where your spyder executable is by running in Terminal:
which spyder
This should yield ~/anaconda/bin/spyder
if you installed spyder via Anaconda, /opt/local/bin/spyder
if you used MacPorts or something similar.
Create a file called spyder
in your Applications
directory and make it executable. Then, fill it with the output of the previous command, followed by a &; exit
:
touch /Applications/spyder
chmod +x /Applications/spyder
echo -e '#!/bin/bash'"\n~/anaconda/bin/spyder &\nexit" >> /Applications/spyder
(if you use a different shell (e.g. tcsh
), replace bash
by that)
Under Terminal -> Preferences -> Profiles -> "default profile" -> Shell -> When the shell exits: Select "Close if the shell exited cleanly"
Optional:
Download the spyder Icon from here and open it in Preview. Copy its contents by hitting cmd+C.
In Finder, locate /Applications/spyder
and open its "Get Info" pane by hitting cmd+I. Select the icon in the top left corner with your mouse and hit cmd+V.
You can use Automator to create an Application that will run Unix Script. Open Automator when it asks for document type put "Application"
Search and click on "Run Shell Script". You can leave /bin/bash as it is and type in the box the location of spyder (as given by typing which spyder in the terminal). Then you save the file and you are done. This also gets rid of the problem I had when terminal runs in the background and gives you a application you can drag to the dock. You can also change the logo as suggested above.
(I did this with Mac OS 10.10 and a Anaconda 2.3.0)
The accepted answer has two drawbacks: a console windows appears when starting spyder and one cannot keep a spyder icon in the dock. These drawbakcs can be avoided by creating a proper Mac application bundle for spyder, which is surprisingly easy to do.
To convert /usr/local/bin/spyder3
(the result of which spyder3
on my machine) into a traditional Mac application:
Create a Mac application bundle (basically a folder structure containing an executable file):
cd /Applications
mkdir -p spyder.app/Contents/MacOS
echo -e '#!/bin/bash'"\n /usr/local/bin/spyder3 $@" >> spyder.app/Contents/MacOS/spyder
chmod +x spyder.app/Contents/MacOS/spyder
Create a plain text file called Info.plist in the Contents folder (i.e. at spyder.app/Contents/Info.plist) with the following content:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>CFBundleExecutable</key>
<string>spyder</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>3.1.4</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>3.1.4</string>
</dict>
</plist>
(Optional) Create an app icon like in steps 4 and 5 of the accepted answer.
Voilà, spyder has become suddenly much more Mac-friendly!
EDIT:
One can further improve the mac-friendliness of spyder by:
Preventing the generic python rocket icon to appear besides the spyder icon
For this, uncheck in spyder the option Tools -> Preferences -> iPython console -> Graphics -> Activate (matplotlib)
Making spyder the default editor for .py files.
This one is more tricky. First make sure that the content of spyder.app/Contents/MacOS/spyder reads
#!/bin/bash
/usr/local/bin/spyder $@
Create then an automator script containg a single action "Execute a shell script". Paste the following (bash) script in it:
for f in "$@"
do
open /Applications/spyder.app --args $f
done
if [ -z "$f" ]; then
open /Applications/spyder.app --args ~
fi
Choose "As argument" for the input data, as shown in the screenshot below (the "--args ~" is missing in the screenshot but it is needed to avoid an error when launching spyder without any file).
Save this script as an application called "SpyderOpener" for instance.
Make SpyderOpener the default application for opening .py files (by using the Finder "Get Info" dialog on a .py file)
Navigate to anaconda/bin, locate spyder (or IPython, etc.), and drag it to the dock — but put it in the documents section at the end. Then you’ll have easy access to it, and when you click on it Mac OS X will launch a shell that runs it, and it will appear in the applications section, so that you can bring the running application forward by clicking on it.
You can open spyder by pointing Quicksilver to ~/anaconda/bin/spyder
(you can add it to your catalog so that it always finds it).
A very simple method not requiring use of Terminal is essentially to create a spyder.app package in Applications and copy the spyder exec file from Anaconda into this folder. Clicking on the package will run spyder as an app, and you can right-click the dock icon to keep it in the dock.
Below are the step-by-step instructions.
We first create the spyder.app folder in Applications:
Open the Applications folder in Finder.
Right-click and create "New Folder".
We then copy the exec spyder file:
In a new Finder window, open your home folder (it should have a simple picture of a house as the icon). A shortcut is to press shift+command+H while Finder is open.
Open the anaconda3 folder, and then open the folder named 'bin'.
Note: if anaconda3 isn't installed in your home directory, just search for 'anaconda3' with exact filename matches in Finder and open the file.
Paste the copied exec file into the spyder.app package:
In the Finder window open to Applications, right-click the spyder.app created above and select "Show Package Contents".
Right-click in the window and paste the exec file.
Now, when you return to the Applications folder, double-click on the spyder.app package and spyder should run. Right-click the icon in the dock and select "Keep in Dock" to keep the app in the dock when not running. You can also create the icon for the app as indicated in 4 and 5 of the original answer.