Updating Python3 and Pip3 on Mac - python

I have two versions of python3 installed on my computer. They are located here:
/usr/local/bin/python3
/usr/bin/python3
I have set my PATH variable to use the first version. Running "which python3" routes to this version: /usr/local/bin/python3 -- this is what I want.
Unfortunately, pip3, and yet another version of Python, are installed in a different location (I think the version that comes pre-installed with mac). When I run "pip3 --version" I get the below:
pip 20.1.1 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)
Shouldn't these match? Is there a way to make sure python3 uses the pip3 version via /usr/local/bin/pip3? Do I just need to change / add it to my path somehow?
Another option is to uninstall everything with homebrew (what I used to originally install python3), and then reinstall. However, apparently, per my co-worker, we need to stay on python3.7. I'm worried if I reinstall python3, it will default to 3.8 or higher.
Please help!

There are a few things that I have found increase the chances of success here:
don't mess with the Mac-installed default Python
don't use homebrew to install Python
use pyenv to install and manage Python versions
Here's a useful write-up on The right and wrong way to set Python 3 as default on a Mac.

Related

Confused by multiple versions of pip on mac

I am trying to setup Python 3 on my mac computer and I seem to have many versions of pip on my computer, not sure which I should be using.
When I run pip --version in the terminal I get pip 19.2.3 from /Library/Python/2.7/site-packages/pip-19.2.3-py2.7.egg/pip (python 2.7) which I am fairly certain is just the version that comes with mac os.
When I run python3 -m pip --version I get pip 20.1.1 from /Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)
When I run pip3 --version I then get pip 19.0.3 from /Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.7/lib/python3.7/site-packages/pip (python 3.7)
I was hoping somebody could explain the differences between
The first and third pips seem to be from the OS (assuming you're on Catalina?) and the second one seems to be the one you've installed.
See
https://docs.python.org/3/using/mac.html
and
Python 3.7.3 Inadvertently Installed on Mac OS 10.15.1 - Included in Xcode Developer Tools 11.2 Now?
The quick and nasty answer is each installation of python can have its own pip, which in turn will have a different pipenv. This is all based off of your path. Most people opt to use virtualenv to create an app specific python environment so as to not impact other python applications which depend on specific conflicting versions.

How do I make pip point to pip for python 3.7 instead of python 3.6?

Everytime I try to update pip for version 3.7 of python it just does it for python 3.6.
python --version returns 3.7.3, but pip --version returns the version with (python 3.6) at the end in parentheses
pip3.7 [command]
You could make an alias which you update whenever you want to update the version of pip you are using.
This isn't the specific answer you are looking for, but it should be worth noting that just using pip can get nasty on systems with multiple python environments installed (hence, your SO question here!)
I'd suggest that you consider targeting your python binary, and then use pip from there:
/path/to/python -m pip <pip commands here>
With this, you will never be confused about which python is getting packages installed to it. It's drawn out, and it's not fun to type all that, but with multiple python environments on a system, it can save a headache and avoid future confusion!

Pip error: Fatal error in launcher: Unable to create process using '"'

I've seen many threads about this, and have tried all options except for completely wiping Python off of my machine and re-downloading everything...
I'm using a Windows 10, 64-bit machine, and had already downloaded Python2.7. Commands like 'C:\>pip install seaborn' were not an issue.
I recently downloaded Python3.6, and now my pip will not work - it returns the error in the title.
I have added C:\Python27, C:\Python36, C:\Python27\Scripts, C:\Python36\Scripts to my Path, and still it won't work.
If I type in the command C:\>python27 -m pip install seaborn, however, the pip works. I am really confused why I can no longer just type in pip install and have it work.
Thanks in advance!
You have two versions of Python added to path. To differentiate between 2.7 and 3.6 you have to tell it which version you want otherwise each pip conflicts with the other (it does not know what to install and where) in other words you type pip you could either mean for Python 2 or for Python 3.
Do not rename pip it will break your system (you should not need to rename). Instead use those already provided..
Your system should have these already:
pip is universal. Best for one installation.
pip3 for Python 3. Best to distinguish between Python 2 and 3
pip3.6 to distinguish between different Python 3 installations.
The same goes for Python 2 installation.
pip, pip2 and pip2.7.
You need to use either pip3 (or pip2) or pip3.6 (or pip2.7) to install in future. This will allow the different versions to be recognised:
For Python 2:
pip2 install seaborn
For Python 3:
pip3 install seaborn
You should also now use shebang lines as well now (if you are not already) to distinguish between versions.
the issue is the ambiguity between the two pip that you've mentioned in the Environments. As you mentioned the issue only started occurring when you installed python3 on the same system where python2 was installed and both have pip and hence when you fire up pip in your cmd, Windows System isn't able to pick one out of the two.
Why does your C:>python27 -m pip install seaborn work?
Well it's quite simple, since you've mentioned the python27 there, windows knows exactly which pip you're talking about.
How to fix it?
see the edits for this section. (I tried this, it didn't work) Removed it from the final answer to avoid confusion.
Alternatively, what you can do is,
rename your python.exe for python 3 to python3. Don't forget to put it inside your PATH environment. Just use python for python 2, python3 for python 3.
Their pip are separated, pip for python 2. pip3 for python 3.
Now, run and see the below commands behave:
# will return the default version of pip
pip --version
# will use the Python 2 version of pip
pip2 --version
# will use the Python 3 version of pip
pip3 --version
Okay so I finally worked it out...
I uninstalled Python3.6 and deleted all relevant folders.
I then went to Control Panel>Programs>Progams and Features and repaired my Python2.7 program. pip works now (I think it got messed up since I tried to rename the universal pip.exe file -> don't do that!!).
After re-downloading Python3.6, I put my universal pip.exe download from Python3 in a different directory so the Path would not get it confused. I now have Paths for both pip2 and pip3 and all is okay.
Thanks for your help!
This is how I solved this issue on my end: (short answer, remove this folder C:\Python27)
Problem: I installed python 3, after uninstalling python 2.7. The issue here is that pip remains behind even after you uninstall python 2.7.
Solution:
1. Uninstall python 3 (if you have it installed).
2. Just in case, I would uninstall python 2.7.
3. This is the key: go to C:\Python27 ... and delete the entire directory (which also contains pip).
This solution is good for those that are fine with ONLY running Python 3 on their machines (which was my case).

pip: How to deal with different python versions to install Flask?

I have different versions of Python installed on my Ubuntu machine (2.7.11, 2.7.12, 3.5). I would like to install Flask on the 2.7.12 as it used by Apache.
I have three pip{version} in my PATH which are: pip, pip2, and pip2.7. How do I know which one is for which python version.
I have already read Here but it didn't help my case as I need to differentiate between minor version number 2.7.11 and 2.7.12.
One thing is that I tried pip{version} install Flask for all three pips but the 2.7.12 still can't import Flask.
Any help is much appreciate it.
Thanks
You should always create virtualenvs for your projects. You can create one like
virtualenv -p <path/to/python2.7.12> <path/to/new/virtualenv/>
inside that virtualenv pip and python will always select the right interpreter and path.
You can find it out by trying to run this: pip --version. Output will be something like this: pip 8.1.2 from /usr/lib/python2.7/site-packages (python 2.7). This way we can see that it is for python2.7 in my case.

Which version of Pip to use with my Python installs?

Being new to Python, I'd love to clear up a few points that I couldn't get from reading various articles and tutorials.
After using Homebrew to install Python3, I noticed that it had installed both Python3 and Python3.4. I was also a little surprised that there are now three versions of pip on my machine too; pip, pip3 and pip3.4.
I created a new virtualenv and told it to use Python3, using the following command:
virtualenv -p /usr/local/bin/python3 mysite
I was also surprised that the version of Python that it installed in my VM was 3.4.
Is it safe to have these multiple version of Python and Pip hanging around on my machine?
Am I right to assume that I should take extra care to use the matching version of pip with Python, for example, pip3.4 with Python3.4?
Yes, it is safe. Python uses this naming like python3.4, python3.5 etc to differentiate between releases. python3 is a symbolic link to the current python3.x version. Pip follows the same convention.
If you're using python3.4 explicitly, you should be using pip3.4 specifically as well. Otherwise, just use python3 and pip3. For Python 2, you can simply use python (which, unless you installed the Homebrew version as well), will be the system Python), and ditto for pip. python2.7 and pip2.7 may also work.
In general, to find out which Python version goes with which pip you're using, try:
pip --version
and you'll see the Python included in the result.
No need to worried about if you have multiple version of Python and Pip installed. just check your version by writing in terminal :
$ brew info python
or to check the version of pip write in terminal :
$ brew info pip
and make sure you have updated your both pip and python version (write in terminal $ brew upgrade pip/python)
and other way to install python is go to https://www.python.org/downloads/ and choose as your requirement, there is two version available 2.7.9 & 3.4.3 ,
after installing python write in terminal $ python -V to check its version :) Hope it will help :)

Categories

Resources