5

I'm currently working on a Mac with Mojave. I have successfully installed python 3.7 with brew

    brew install python3

But I have tried several methods to install pip for python 3.7 (installing with get-pip.py, easy_install pip, etc.), which had worked for installing pip in the python 2.7 folder, but not in the python 3.7.

Currently when I call

  pip --version

I get

pip 18.1 from /Library/Python/2.7/site-packages/pip (python 2.7)

And pip3 seems not to exist.

How can I get pip3 installed in the python 3.7 folder? Thanks!

PthaloDev
  • 71
  • 1
  • 1
  • 3

5 Answers5

3

If you want to ensure pip installed for python 3.7, try something like this:

wget https://bootstrap.pypa.io/get-pip.py
sudo python3.7 get-pip.py
Antwane
  • 20,760
  • 7
  • 51
  • 84
  • I already tried this solution but it doesn't seem to work :/ I get a "Successfully installed pip-18.1" message but when I ask "pip --version", I get "pip 18.1 from /Library/Python/2.7/site-packages/pip (python 2.7)" – PthaloDev Oct 29 '18 at 09:41
2

Ok, so I still don't quite understand what's going on with pip3 in my device, but I found a way to install packages with pip in the right Python version:

python3 -m pip install [package]

It worked to install numpy which was my primary objective.

PthaloDev
  • 71
  • 1
  • 1
  • 3
1

Maybe you're using an older version of Brew?

In that case run brew postinstall python3

Rupaksh Paul
  • 112
  • 1
  • 11
1

For python 3.x, the command is pip3

Dorian B
  • 108
  • 10
0

I think you should be using pip3 --version instead of pip --version,provided pip3 was installed successfully.

Check all versions of pip installed on your machine using ls -ltr /usr/local/bin|grep pip

Then use the correct executable to query the version.

For example on my machine I get:

ls -ltr  /usr/local/bin|grep pip
lrwxr-xr-x  1 abhinav  admin                    33 May  8 03:32 pip3.6 -> ../Cellar/python/3.6.5/bin/pip3.6
lrwxr-xr-x  1 abhinav  admin                    31 May  8 03:32 pip3 -> ../Cellar/python/3.6.5/bin/pip3
lrwxr-xr-x  1 abhinav  admin                    36 May  8 03:32 pip2.7 -> ../Cellar/python@2/2.7.15/bin/pip2.7
lrwxr-xr-x  1 abhinav  admin                    34 May  8 03:32 pip2 -> ../Cellar/python@2/2.7.15/bin/pip2

Now if I do

pip2 --version
pip 18.1 from /usr/local/lib/python2.7/site-packages/pip (python 2.7)


pip3 --version
pip 18.1 from /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/pip (python 3.6)

As you can see in the above output, the path shown to you is dependent on where the executable is pointing.

So make sure your pip is not pointing to python 2.7

Abhinav
  • 1,720
  • 4
  • 21
  • 33
  • currently pip3 seems unavailable. When I do "ls -ltr /usr/local/bin|grep pip" I get "-rwxr-xr-x 1 root admin 215 29 oct 09:41 pip -rwxr-xr-x 1 root admin 215 29 oct 09:41 pip2 -rwxr-xr-x 1 root admin 215 29 oct 09:41 pip2.7" and "pip3 --version" returns nothing – PthaloDev Oct 29 '18 at 10:05
  • are u able to use `python3` shell? – Abhinav Oct 29 '18 at 10:08
  • ok..are u sure you installed `pip` for `python3`,for @antwane reply you responded it installed correctly .You can check for pip in one of the directories of `$PATH` – Abhinav Oct 29 '18 at 12:08
  • Have you tried creating a virtual environment for python3.7 and using that? – Natsfan Oct 29 '18 at 23:10