hitgugl.blogg.se

Mac python install pip
Mac python install pip









mac python install pip
  1. #Mac python install pip how to#
  2. #Mac python install pip update#

#Mac python install pip update#

So first, great job on always using an environment (I will argue why this is a best practice later on this blog post)! But I would honestly still argue for using python -m pip even when it strictly isn't necessary.įirst, if you're on Windows you will want to still use python -m pip just so you can update pip in your environment. Usually when I explain this to a group of people inevitably someone will say "I always use a virtual environment and so this doesn't apply to me". What about when I am in an activated environment? But if you do python -m pip install -upgrade pip you avoid that issue as it's python.exe that's running, not pip.exe. Basically because pip.exe is considered running when you do pip install -upgrade pip, Windows won't let you overwrite pip.exe. If I say python3.8 -m pip then I know pip will be using and installing for my Python 3.8 interpreter (same goes for if I had said python3.7).Īnd if you're on Windows there is an added benefit to using python -m pip as it lets pip update itself. OK, but what happens when Python 3.7.6 comes out? Your pip command would have gone from using Python 3.8 to Python 3.7.īut when you use python -m pip with python being the specific interpreter you want to use, all of the above ambiguity is gone. Now you may be saying, "I always install the latest versions, so that would mean Python 3.8.0 was installed last since it's newer than 3.7.5". Unless you know when you installed each version and thus what the last copy of pip was written to /usr/local/bin/pip you don't know what interpreter pip will be using for the pip command. Can you now tell me what interpreter pip is tied to? In that case both versions of Python are installed in /usr/local/bin. But let's say you installed both manually maybe your OS came with Python 3.7.3 and you installed Python 3.7.5. OK, so as long as you remember where you installed Python 3.7 and 3.8 and that it was different directories you will know which version of pip comes first on PATH. is /usr/bin before or after /usr/local/bin (which are common locations for Python to be installed into, and typically /usr/local/ comes first). First you would have to know what my PATH is set to, e.g. Without more details the answer is you don't know. Now, if you were to type pip in your terminal, which Python interpreter would it install for? Let's say I have two versions of Python installed, like Python 3.7 and 3.8 (and this is very common for people thanks to Python coming installed on macOS and Linux, let alone you may have installed Python 3.8 to play with it while having previously installed Python 3.7). So you might be saying, "OK, but can't I just run pip by executing the pip command?" And the answer is "yes, but with a lot less control", and I will explain what I mean by "less control" with an example. You can read the docs on -m if you're unfamiliar with the flag and how it works (it's very handy). So /usr/bin/python3.7 -m pip means you are executing pip for your interpreter located at /usr/bin/python3.7. To begin with, python -m pip executes pip using the Python interpreter you specified as python. So this blog post is meant to explain what python -m pip is and why you should be using it when you run pip.

#Mac python install pip how to#

Now I'm not sure if it was specifically me that told Mariatta about python -m pip, but the chances are reasonable that it was me as I have been asking for it to become the instructions provided on PyPI on how to install a package since 2016. Likely from or any of you have a talk/blog post on this, so I can share with people?- Mariatta 🤦 October 29, 2019

mac python install pip mac python install pip

` but now I can't remember the source of this information. I learned sometime ago that we should be doing Fellow core developer and Canadian, Mariatta, asked on Twitter about python -m pip and who told her about that idiom along with asking for a reference explaining it:











Mac python install pip