-
Notifications
You must be signed in to change notification settings - Fork 3
MacOS
If your new using your mac as a Unix computer, taking advantage of the command line and everything, this is a good place to start. You can find more details for every of these tools on the Internet but this is a good place to know what you are going to need.
Unix is a (super-wide) family of operating system (OS). What you need to know for this:
- MacOS is Unix based,
- Linux is Unix based,
- Windows is not Unix. Why does it matter?
- A lot of server, including ours are Linux,
- Linux is a amazing, enormous, high quility open source community. So basically your computer is natively compatible with a lot of tools and with our servers! This will save you a lot of pain.
There are a lot of applications to get a command line interface. But we can stick with Mac's Terminal, which is more than fine. Open it, we're going to work with that. The command line is used to execute and control a lot of program that don't have a grahical interface. It also has its own scripting language (Bash is default on Mac) but we're not going to worry about that for now.
Why wouldn't you want a graphical interface? Well a lot of valuable programs simply don't have one. They are heavy to use, to maintain, and they get visually outdated pretty quickly. For now, you can see the terminal as a way to get access to all this ecosystem. As you get more familiar, you will feel that no interface can also be easier to use and more complete.
You've propably written such programs if you've run some code before. This would have been in a graphical interface (Spyder, PyCharm etc. for Python; Codeblocks, VisualStudio, Xcode etc. C/C++; Eclipse etc. for Java) but the code you ran didn't need that interface and can actually be run on the command line. This is easier for deploying it on the servers, running it automitcally, saving results, etc.
First thing we are going to install a package manager. A package manager is an App Store, with more nerdy features.
- If the program you want is register with your package manager, you don't have to look for it and download the right version for your computer. It is done for you.
- It manage dependencies (if the program you want needs other programs or library) for you,
- It manage installations for you and put everything in a controlled location on your computer. You've probably already had to install a weird programs which had a lot of that files you didn't understand and you didn't what you should do, well this is done for you.
- It manages the updates.
The notorious one on Linux is
apt-get
, on Mac, we're going to install Homebrew. Go on the website, copy-paste the installation line, and hitEnter
. Homebrew is known to be very friendly, so don't worry and answer its questions.
Once you're set, you can search for packages typing
brew search something
any time in your Terminal and
brew install something
Other useful command are brew doctor
, brew uninstall
, brew list
and brew help
which lists everything you can do.
You can run brew install git
. Git is a program you're deinitly going to use but this is for another topic.
Homebrew has an extension to also install graphical applications for you. It's called Caskroom and pretty much has every mainstream free App that you usually download on the Internet (Chrome, Firefox, Spotify, you name it). To add the extension, type
brew tap caskroom/cask
And then everything is the same but adding the cask
keyword. For instance:
brew cask search firefox
brew cask install spotify
Why would you want to do this? Well, hopefully you're gonna learn to love the command line and realize that this is actully quicker than going to the website, download, extract, drag and drop, eject the extracted disk. If you change computer, you're going to love doing it, even more if you have done it before because you can export the list of installed apps to have them install elsewhere.
We're not going to learn python, just how to install it properly for your Mac. You can and will have multiple verison of Python on your computer, there actually already one. If you type
python
(type exit()
to exit Python)
a Python interpreter will open. And if you type
python my_file.py
it's going to execute the python inside "my_file.py".
If you haven't installed any Python the python program used is the one in "/usr/bin/python". This is the Python used and controlled by the operating system, so as a good rule of thumbs, we're going to leave it this way and not used it. To install your very own Python (2.7) run
brew install python
Homebrew has taken care of everything for you. Now when you call python
, it's going to be your very own Python.
A very useful command with Python (but not only) is which command
. This command tells you what program you would be running if you type command
. When you type
which python
before the installation, you would see "/usr/bin/python", now you have somehting like "/usr/local/opt/python/libexec/bin/python" (note: it's not exactly the location of the Python you run because this location is actually an alias for somewhere else, but Homebrew is taking care of everything).
python
actually runs Python2.7, so it has a couple of nicknames, you can also type python2
, python2.7
and more. You can also play with these and which
and try to get your head around it :)
We're also goign to install Python3 with
brew install python3
Because python
is already taken, we will have to use explicitly python3
(or python3.6
etc.) to use it. If you don't know why you're writting Python2.7 code, then don't and run Python3! Still you should have Python2.7 for other project that are older.
Homebrew also installed pip
and pip3
which are the package manager for Python2 and Python3 (#Inception). You're going to need them but we're not going to cover that here.