149

OS X (Mavericks) has Python 2.7 stock installed. But I do all my own personal Python stuff with 3.3. I just flushed my 3.3.2 install and installed the new 3.3.3. So I need to install pyserial again. I can do it the way I've done it before, which is:

  1. Download pyserial from pypi
  2. untar pyserial.tgz
  3. cd pyserial
  4. python3 setup.py install

But I'd like to do like the cool kids do, and just do something like pip3 install pyserial. But it's not clear how I get to that point. And just that point. Not interested (unless I have to be) in virtualenv yet.

17 Answers 17

159

UPDATE: This is no longer necessary as of Python3.4. pip3 is installed as part of the general Python3 installation.

I ended up posting this same question on the python mailing list, and got the following answer:

# download and install setuptools
curl -O https://bootstrap.pypa.io/ez_setup.py
python3 ez_setup.py
# download and install pip
curl -O https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py

Which solved my question perfectly. After adding the following for my own:

cd /usr/local/bin
ln -s ../../../Library/Frameworks/Python.framework/Versions/3.3/bin/pip pip

So that I could run pip directly, I was able to:

# use pip to install
pip install pyserial

or:

# Don't want it?
pip uninstall pyserial
Sign up to request clarification or add additional context in comments.

7 Comments

to avoid confusion with pip that installs for Python 2.7, you could create the symlink named pip3 instead of ambiguous pip
I didn't have to create a symlink, one was created automatically named pip3
Following your answer step by step solved my problem. Thanks!
bootstrap.pypa.io/ez_setup.py and bootstrap.pypa.io/get-pip.py are the updated links, though pip3 comes installed with python3 as OP mentioned.
|
73

I had to go through this process myself and chose a different way that I think is better in the long run.

I installed homebrew

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

then:

brew doctor

The last step gives you some warnings and errors that you have to resolve. One of those will be to download and install the Mac OS X command-line tools.

then:

brew install python3

This gave me python3 and pip3 in my path.

pieter$ which pip3 python3
/usr/local/bin/pip3
/usr/local/bin/python3

2 Comments

Thanks for this, was looking for a good solution. For people seeing this in the future (who will get the same message I got from ruby), the Homebrew installer has moved and the new command is: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Latest command /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
66

Install Python3 on mac

1. brew install python3
2. curl https://bootstrap.pypa.io/get-pip.py | python3
3. python3

Use pip3 to install modules

1. pip3 install ipython
2. python3 -m IPython

:)

3 Comments

Just to clarify for others, the script downloaded is from the official host for pip - pypi.python.org/pypi/pip
Please add https to this example
@GardnerBickford Added https
35

Here is my simple solution:

If you have python2 and python3 both installed in your system, the pip upgrade will point to python2 by default. Hence, we must specify the version of python(python3) and use the below command:

python3 -m pip install --upgrade pip

This command will uninstall the previously installed pip and install the new version- upgrading your pip.

This will save memory and declutter your system.

Image - How the upgrading of pip in Python3 works on MacOS

3 Comments

Thanks! This is exactly what I was looking for — running macOS Catalina.
This is by far straight to the point solution!
this is the answer i was looking too
15

Plus: when you install requests with python3, the command is:

pip3 install requests

not

pip install requests

Comments

13
  1. brew install python3
  2. create alias in your shell profile

    • eg. alias pip3="python3 -m pip" in my .zshrc

➜ ~ pip3 --version

pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

Comments

7

To use Python EasyInstall (which is what I think you're wanting to use), is super easy!

sudo easy_install pip

so then with pip to install Pyserial you would do:

pip install pyserial

6 Comments

How does easy_install determine that it's for python3? I have a \usr\local\bin\easy_install dated Sep 13 2012. I'm suspicious that is from/for the stock 2.7. Sadly, easy_install --version isn't helpful. --help doesn't even give any useful hints.
@TravisGriggs - do you also have 2.7 installed? i was assuming you were only using 3.3.x.
I have not uninstalled the stock 2.7 version that is part of OSX. That would seem like a Bad Idea(tm).
@TravisGriggs, well uninstalling 2.7 can be a bad idea if not done correctly. try typing which easy_install in terminal following by less <path/to/>easy_install. It should give me more information on the version you're using.
Yeah, I had checked that. It's a binary, not a symlink. Since python3 mostly installs in /Library/Frameworks/Python/..., that makes me strongly suspicious that it is for 2.7.
|
6

On Mac OS X Mojave python stands for python of version 2.7 and python3 for python of version 3. The same is pip and pip3. So, to upgrade pip for python 3 do this:

~$ sudo pip3 install --upgrade pip

Comments

5

Also, it's worth to mention that Max OSX/macOS users can just use Homebrew to install pip3.

$> brew update
$> brew install python3
$> pip3 --version
pip 9.0.1 from /usr/local/lib/python3.6/site-packages (python 3.6)

Comments

4

On MacOS 10.12

download pip: pip as get-pip.py

download python3: python3

  1. install python3
  2. open terminal: python3 get-pip.py
  3. pip3 is available

Comments

4

pip is installed automatically with python2 using brew:

  1. brew install python3
  2. pip3 --version

1 Comment

$ which pip3 python3 /usr/local/bin/python3 getting result but when I try pip3 --version then error: pip3: command not found
1

simply run following on terminal if you don't have pip installed on your mac.

sudo easy_install pip

download python 3 here: python3

once you're done with these 2 steps, make sure to run the following to verify whether you've installed them successfully.

python3 --version
pip3 --version

Comments

0

For a fresh new Mac, you need to follow below steps:-

  1. Make sure you have installed Xcode
  2. sudo easy_install pip
  3. /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  4. brew doctor
  5. brew doctor
  6. brew install python3

And you are done, just type python3 on terminal and you will see python 3 installed.

Comments

0

I had the same problem with python3 and pip3. Decision: solving all conflicts with links and other stuff when do

brew doctor

After that

brew reinstall python3

Comments

0

I'm using MacOS 11.6 and in my case I did two things;

  1. Install Python 3 from https://www.python.org/downloads/macos/ clicking on first link Download macOS 64-bit universal2 installer from Stable Releases list

  2. Create alias for Python3 running the following command on Terminal echo "alias python='/usr/bin/python3'" > ~/.bash_profile

After that open a new terminal and type python -V to check if the version of python 3 is enabled by default for your use so now you can use the command pip3 to install your packages like pip3 install somepackage

Comments

0

use port to install it, it is better than brew, in case you have an old machine.

sudo port install py38-pip

Comments

0

I had "-bash: pip: command not found" issue, even though I had "pip3 --version" showing result on " pip 21.2.4 from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/site-packages/pip (python 3.9)".

:::My solution on mac::: (1)at terminal do: vi ~/.bash_profile

(2)edit file: enter image description here

(3)save now: source ~/.bash_profile

check : pip --version

it worked

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.