5

In summary, it seems I get into a loop where pip thinks I am using an outdated version of pip but when I try to upgrade it does NOT allow me. So I attempt an installation (from this question Jupyter Notebook can't find modules for python 3.6):

(automl) brandomiranda~ ❯ pip3 install ipykernel --upgrade
python3 -m ipykernel install --user
Requirement already up-to-date: ipykernel in /usr/local/lib/python3.6/site-packages (5.1.3)
Requirement not upgraded as not directly required: jupyter-client in /usr/local/lib/python3.6/site-packages (from ipykernel) (5.3.4)
Requirement not upgraded as not directly required: traitlets>=4.1.0 in /usr/local/lib/python3.6/site-packages (from ipykernel) (4.3.3)
Requirement not upgraded as not directly required: appnope; platform_system == "Darwin" in /usr/local/lib/python3.6/site-packages (from ipykernel) (0.1.0)
Requirement not upgraded as not directly required: tornado>=4.2 in /usr/local/lib/python3.6/site-packages (from ipykernel) (6.0.3)
Requirement not upgraded as not directly required: ipython>=5.0.0 in /usr/local/lib/python3.6/site-packages (from ipykernel) (7.11.1)
Requirement not upgraded as not directly required: jupyter-core>=4.6.0 in /usr/local/lib/python3.6/site-packages (from jupyter-client->ipykernel) (4.6.1)
Requirement not upgraded as not directly required: pyzmq>=13 in /usr/local/lib/python3.6/site-packages (from jupyter-client->ipykernel) (18.1.1)
Requirement not upgraded as not directly required: python-dateutil>=2.1 in /usr/local/lib/python3.6/site-packages (from jupyter-client->ipykernel) (2.8.1)
Requirement not upgraded as not directly required: six in /usr/local/lib/python3.6/site-packages (from traitlets>=4.1.0->ipykernel) (1.11.0)
Requirement not upgraded as not directly required: ipython-genutils in /usr/local/lib/python3.6/site-packages (from traitlets>=4.1.0->ipykernel) (0.2.0)
Requirement not upgraded as not directly required: decorator in /usr/local/lib/python3.6/site-packages (from traitlets>=4.1.0->ipykernel) (4.4.1)
Requirement not upgraded as not directly required: backcall in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (0.1.0)
Requirement not upgraded as not directly required: pickleshare in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (0.7.5)
Requirement not upgraded as not directly required: pexpect; sys_platform != "win32" in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (4.7.0)
Requirement not upgraded as not directly required: prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0 in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (3.0.2)
Requirement not upgraded as not directly required: jedi>=0.10 in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (0.15.2)
Requirement not upgraded as not directly required: pygments in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (2.5.2)
Requirement not upgraded as not directly required: setuptools>=18.5 in /usr/local/lib/python3.6/site-packages (from ipython>=5.0.0->ipykernel) (39.0.1)
Requirement not upgraded as not directly required: ptyprocess>=0.5 in /usr/local/lib/python3.6/site-packages (from pexpect; sys_platform != "win32"->ipython>=5.0.0->ipykernel) (0.6.0)
Requirement not upgraded as not directly required: wcwidth in /usr/local/lib/python3.6/site-packages (from prompt-toolkit!=3.0.0,!=3.0.1,<3.1.0,>=2.0.0->ipython>=5.0.0->ipykernel) (0.1.8)
Requirement not upgraded as not directly required: parso>=0.5.2 in /usr/local/lib/python3.6/site-packages (from jedi>=0.10->ipython>=5.0.0->ipykernel) (0.5.2)
You are using pip version 10.0.1, however version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Installed kernelspec python3 in /Users/brandomiranda/Library/Jupyter/kernels/python3

ok fine, I will upgrade but then it thinks its already upgraded:

(automl) brandomiranda~ ❯ pip install --upgrade pip
Requirement already up-to-date: pip in ./miniconda3/envs/automl/lib/python3.7/site-packages (19.3.1)

but when I try the installation again it fails with the same message. It seems like a chicken and egg problem. Anyone know what's going on?


Outdated:

I recently did a pip3 list to check what modules/projects I had installed in my virtual environment and I got a suggestion to upgrade pip. I tried but I can't seem to make it update/upgrade. I did:

$ pip3 list
namespaces (4.2.0)
pip (8.0.2)
scikit-learn (0.18.1)
setuptools (19.4)
six (1.10.0)
wheel (0.26.0)
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

so I tried doing that and it said it was working:

$ pip install --upgrade pip
Requirement already up-to-date: pip in /Users/user/home_simulation_research/hbf_tensorflow_code/venv/lib/python2.7/site-packages

since it said its alread there I did pip3 list again and it kept saying I didn't actually have it upgraded. Since updating with the standard pip command didn't work I instead tried using pip3 to do the update but it still didn't work:

pip3 install --upgrade pip3
Collecting pip3
  Could not find a version that satisfies the requirement pip3 (from versions: )
No matching distribution found for pip3
You are using pip version 8.0.2, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Why doesn't it work?


Just when I thought it didn't work I tried using pip3 to upgrade pip and pip3 to upgrade pip3. For some reason the later doesn't seem to work but the first one does. i.e. doing:

$ pip3 install --upgrade pip

worked (or at least pip3 list) stopped requesting me upgrade. Why is that? Is it just me or is this really strange behaviour?

Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
  • `pip3` is just an alias for `pip` running on Python 3.x, there is no `pip3` package. `pip install --upgrade pip` upgrades the version you use on Python 2.x, `pip3 install --upgrade pip` upgrades the version you use on Python 3.x. – jonrsharpe Jan 11 '17 at 00:17
  • 1
    try to re-install it once after uninstalling :D –  Jan 08 '20 at 16:59
  • @ChinkySight XD great idea! here is how to do that: https://stackoverflow.com/questions/21012597/how-to-uninstall-pip-on-osx `pip uninstall pip` – Charlie Parker Jan 08 '20 at 17:06
  • Check if you have pip also installed by your package manager `yum/apt/whatever`, maybe you are "seeing" a certain pip, but when updating, the installation of one of the dependencies tries, for some reason, to call pip too and it sees another one (different PATH or shell ). A good old find (`sudo find / -name 'pip'`) would help support the theory. If that's the case uninstall the one installed by the package manager (by using it, don't just delete stuff) – Lohmar ASHAR Jan 09 '20 at 23:41
  • @LohmarASHAR as referenced by the most recent answer, it seems `pip` and `pip3` are using different versions of python for some odd reason. Does that answer your question? – Charlie Parker Jan 10 '20 at 18:16
  • Yeah, I was trying to point out an another way how you can get to some weird situations regarding pip. As for `pip`, `pip3`, `pip2` situation ... `pip` calls `python` which points to whatever is the default version on the machine (can be managed with `update-alternatives`), while the others call the specific version of python, `python2` and `python3` respectively; you can check the "shebangs" of the scripts. – Lohmar ASHAR Jan 11 '20 at 13:39

6 Answers6

6

when you run pip3 list, you are listing packages installed for python3, and when you run pip install --upgrade pip, you are checking updates for python2 packages. when you run pip3 install --upgrade pip3, this would give an error because there is not package named pip3, pip3 is a command line tool provided in the pip package. When you finally run pip3 install --upgrade pip, you are doing the right thing(installing updates for python3, package name is pip).

xiaket
  • 1,903
  • 1
  • 14
  • 8
  • I don't understand, why does pip3 not exist but it actually lets me run something? It seems your answer implies pip2 maps to pip and pip3 maps to pip, so there seems to be a collision. How do I know what pip is doing (e.g. calling pip2 or pip3)? – Charlie Parker Jan 11 '17 at 00:44
  • I have mentioned in my answer, pip3 is a command line tool provided by the pip package. you can check the output of the following two commands to see it: `pip show pip -f`, `pip3 show pip -f` – xiaket Jan 11 '17 at 00:53
  • pip3 is not a package, it's a program within the pip package. – aqua Jan 11 '17 at 02:41
1

What worked for me was to uninstall and install pip.

To uninstall pip do:

pip uninstall pip

although I went to the /usr/local/bin and deleted everything with pip name with:

rm -rf pip*

there were some pip3 things that were still there oddly enough.

Then I install pip with the (deprecated) sudo easy install:

sudo easy_install pip

although that command is deprecated, so something else has to be done in mac but for now that works (and made my jupyter notebook work again thus solving this question Jupyter Notebook can't find modules for python 3.6).

Charlie Parker
  • 5,884
  • 57
  • 198
  • 323
1

If you notice the difference in site-packages path you will get it.

When you are using pip3 /usr/local/lib/python3.6/site-packages path is shown which is python3.6.

Ref:

(automl) brandomiranda~ ❯ pip3 install ipykernel --upgrade
python3 -m ipykernel install --user
Requirement already up-to-date: ipykernel in /usr/local/lib/python3.6/site-packages (5.1.3)

And when you are using just pip you see it is python3.7 and totally different site-packages path ./miniconda3/envs/automl/lib/python3.7/site-packages

Ref:

(automl) brandomiranda~ ❯ pip install --upgrade pip
Requirement already up-to-date: pip in ./miniconda3/envs/automl/lib/python3.7/site-packages (19.3.1)

So both are different : pip3 points to direct system path(/usr/local/lib docs) which is Python3.6 and pip points to a virtual environment's path(./miniconda3/envs/automl/lib/) where python3.7 is installed.

You need to decide which one to upgrade and use. Having virtual environment is best practice.

Shakeel
  • 1,869
  • 15
  • 23
  • I'm always using conda virtual environments, so I don't understand why it's pointing to the system one. Do you mind telling me how to fix it so to use my current active conda virtual environment? – Charlie Parker Jan 10 '20 at 18:15
1

The issue seems to be that new virtual environments are using an old version of pip. Note that pip is installed from a source tarfile (or wheel) included with virtualenv, in the site-packages/virtualenv_support directory.

$ ls -l /path/to/site-packages/virtualenv_support
pip-9.1-py2.py3-none-any.whl

A quick way to workaround the problem is to make sure you upgrade pip whenever you create a new virtualenv, like so:

$ virtualenv venv
$ venv/bin/pip install -U pip

Alternatively, make sure you have the latest version of virtualenv. According to their release notes, virtualenv==16 is using pip==10.

$ pip install -U virtualenv

Finally, since virtualenv looks for pip*.whl in virtualenv_support, this will also work:

$ mv /path/to/site-packages/virtualenv_support/pip*.whl{,bak}
$ pip wheel -w /path/to/site-packages/virtualenv_support/ 'pip==18'

All new virtualenvs will use the version of pip that you installed into virtualenv_support. However, this feels hacky.

(Attempted with virtualenv==16. This results in all new virtualenvs with pip==18.)

Stackoverflow Post - https://stackoverflow.com/questions/51644402/i-keep-getting-a-message-to-upgrade-pip

Chetan Patel
  • 772
  • 4
  • 8
0

instead of pip install, I tend to run python3 -m pip install upgrade --user, to specify which python is intended

chrisckwong821
  • 1,133
  • 12
  • 24
0

To get me out of a similar loop of hell, I simply re-installed pip with the following command :

curl https://bootstrap.pypa.io/get-pip.py | python3.7

Just specify the right python version you want pip to be installed with.

Url is from https://pip.pypa.io/en/stable/installing/

Bluezen
  • 850
  • 9
  • 13
  • I did this, and still when I run pip3 -V it says pip 22.3 from /Library/Frameworks which apparently is unacceptable to Manim it wants it to say from /usr/local – Brad Caldwell Oct 31 '22 at 05:28