Heyyy, so I'm following a video tutorial that requires me to install sklearn, quandl, and pandas.
Unfortunately the video author is using Windows and gave no explanation of what to do if on a Mac. I thought maybe I could use homebrew, so I installed homebrew and tried brew install sklearn, but that didn't work.
Error: No available formula with the name "sklearn"
When I tried pip install sklearn I got
-bash: pip: command not found
I had read this comment by user acidjunk: "a home brew python already has pip." I didn't understand this the first time I read it. Now I understand that pip is included in some Python installations. But I've also since learned that installing that way can result in a double installation of Python, so I'm hesitant about doing that.
Also, the accepted answer for that question about installing pip uses sudo, and a comment was made "Never sudo install a package for any language. This is insecure and will ruin your life later as more and more packages need sudo permissions." which sounds like a reasonable argument, and that's why I haven't installed pip that way.
Another user commented elsewhere on Stack Overflow "I can use install sklearn using pip or home brew", so there must be some piece of the puzzle I'm missing if it worked for them but not for me.
To further complicate matters, another user suggested brew install pip, but when I tried that I got the following message:
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can install
pip via the instructions at:
https://pip.readthedocs.io/en/stable/installing/
Of course I followed the link, but on the page it says: pip is already installed if you're using Python 2 >=2.7.9 or Python 3 >=3.4 binaries downloaded from python.org, but you'll need to upgrade pip.
I have Python 2.7.10 installed, but I didn't get it directly from python.org. I want to make sure that I install it in a way that it will be compatible with homebrew and the packages I mentioned. And I don't think I want to end up with two Pythons installed (unless I need to).
Also, the tutorial author is using Python 3.5.x, so I guess I need to get both 2.7.10 and 3.5.x installed... in a way that they play nicely together. But in any case I don't want to end up with two instances of 2.7.10 in different locations or anything like that.
What's the best way to proceed? Any help greatly appreciated.
This question specifically never really got resolved, despite Slam's helpful answer. Since the question somehow now has 2K views, I think it's worth mentioning what the main problem was. When I posted this question years ago, I didn't know about Python version management or virtual environments, and I don't think using them was as common practice as it is today.
I still don't use Python a lot, but when I do, I use the version management tool pyenv
. Here are links to a few good articles that explain it: 1, 2, 3.
Going hand-in-hand with version management is environment management. I myself am still learning, but for anyone who is as confused as I was when I posted my question, this helpful guide may be the best place to start: What is the difference between venv, pyvenv, pyenv, virtualenv, virtualenvwrapper, pipenv, etc? Every Python beginner course ought to teach this.
sklearn
alias is deprecated. You may give a try with brew install scikit-learn
pip
as system command. This is probably because you're using system-bundled python. Apple is famous for bundling super-old system deps. I propose to install proper python version with brew
. It should install python and pip. Or use official installerEven with current installation, you probably should be able to run pip as module with
python -m pip install -U pip