6

After an hour search, I have found no answer.

My Mac came with Python 2.7, but I have decided to upgrade to python 3.4.

  • I installed python 3.4 from python.org.
  • I can now use python 3.4 from terminal.
  • Pip still tries to download python 2.7 packages - numpy for 2.7 is "up to date".
  • When I try to --upgrade a package, for example numpy, I get "no permission" error. With sudo appended, the output is trash.

How can I let pip know that I am interested in packages for python 3.4?

Requirement already up-to-date: numpy in /Library/Python/2.7/site-packages 

That's the problem. I want numpy to be up-to-date with Python 3.4.

woot
  • 7,406
  • 2
  • 36
  • 55

3 Answers3

1

I would suggest to install a package manager such as macports brew and install the updated python version from them. After the latest version of python is setup use pip to install the version of numpy

In mac ports , you are able to select the default system python without messing with the path your self.

Community
  • 1
  • 1
pyCthon
  • 11,746
  • 20
  • 73
  • 135
  • 1
    When I worked on a Mac, brew made my life so much easier. It's really worth it. Install brew, use it, and don't try to mess with the Python installed in the system directories on the Mac. – steveha Jun 05 '14 at 06:03
1

You should be able to call a specific pip for your install, although it depends on which version you are running:

Starting at version 0.8:

pip-3.4 install numpy

and starting at version 1.5:

pip3.4 install numpy

If you don't have these, you should be able to just download pip and reinstall it, just be sure to call python 3.4 when you run the installer.

woot
  • 7,406
  • 2
  • 36
  • 55
  • 1
    This worked for me. Perhaps the other answers would have also worked, but this seemed the simplest. –  Jun 05 '14 at 04:03
  • You probably know, but change your shebang line and run the scripts directly if you want to only think about which command to run every time you execute a script. For example: `#!/usr/bin/python2.7` – woot Jun 05 '14 at 04:35
1

I would use Homebrew:

brew install python3

This should install Python3.4.1. Then to get pip:

curl -O https://raw.github.com/pypa/pip/master/contrib/get-pip.py
sudo python3 get-pip.py
# Upgrade just in case...
pip3 install -U pip

Then use:

pip3 install numpy

And to run Python, use:

python3

(I only have one Python 3 installation, if you have multiple you'll need to be more specific with the version number)

Dair
  • 15,910
  • 9
  • 62
  • 107