Sean Sean - 4 months ago 36
Python Question

How to install Numpy & pip3 for python3.x then they were installed in python2.7? Conda?

I want to write program in python3 (3.5), hence I installed python3 next to the pre-installed python2 (2.7) on Mac OS X El Captian.

Since my terminal runs python2.7 by default and Numpy is already installed for it, I put

alias python=python3
and expected to be able to install Numpy for python3. when I type
pip install numpy
. This was the generated message:

Requirement already satisfied (use --upgrade to upgrade): numpy in /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages


I also noticed that I have no
pip3
even though I am using python3:
python --version
returned
Python 3.5.2
, but
pip3 install numpy
got me
-bash: pip3: command not found
.

So my questions are:

1) How to install Numpy for python3.x when Numpy is installed on python2.x?

2) How to get pip3?

3) Is it better to use virtual environments, such as Conda, instead of joggling python2 and python3 on the system?

Thank you from a total n00b

Answer

The simplest way on a Mac is with Homebrew:

http://brew.sh/

Install Homebrew, then run:

brew install python3 pip3

Edit --

Python3 includes pip3, but Homebrew occasionally has trouble linking to the correct versions, depending on what has been installed. Running the following command:

brew doctor

And if you see errors relating to python or unlinked kegs, try running:

brew uninstall python python3

And reinstalling after checking brew doctor.

http://unix.stackexchange.com/questions/233519/pip3-linked-to-python-framework-instead-of-homebrew-usr-local-bin

Comments