[PYTHON] When I try to run the pip command after updating pip, I get "No such file or directory"

Problem Unable to use pip command after "sudo pip install --upgrade pip"

After updating pip with sudo pip install --upgrade pip, I tried various pip commands, but it said bash: / usr / bin / pip: No such file or directory.

Solution hash -r

Running hash -r in the terminal fixed it.

Your own interpretation

According to the Reference Site

When the shell executes a command that is not a built-in command, it is necessary to search the environment variable PATH for the corresponding executable file, but frequently used commands are stored in a place called "hash table". "Hash" is a command to display, delete, and add this hash table.

In short, ** OS remembers "non-built-in, frequently used commands" in a hash table **. In other words

  1. When you installed pip, the previous version of pip was uninstalled
  2. However, the hash table still remembers the PASS of the previous version of pip.
  3. Even if I execute the pip command in the terminal, the OS looks at the hash table and looks for the previous version of pip.
  4. The previous version of pip was uninstalled and cannot be found

Is it like that?

What happens next?

According to the Reference Site

hash -r clears the path information stored in the hash table

It seems. This seems to erase even the memories that you do not want to delete other than the information of the previous version. Therefore,

hash -d command name deletes the memory corresponding to the command name.

Also,

If you execute only hash, the path name stored in the hash table and the number of times the command was executed in that path will be displayed.

Next time, I will check the hash table with hash and delete only unnecessary memories with hash -d command name.

Recommended Posts

When I try to run the pip command after updating pip, I get "No such file or directory"
After installing Anaconda3, I get the error "zsh: no such file or directory:/opt/anaconda3/bin/conda" in the command line preferences.
When I try to upgrade pip, I get an infinite loop after failing to upgrade
What to do when [Errno 2] No such file or directory appears in Python
When bus = smbus.SMBus (1) gets IOError: [Errno 2] No such file or directory when trying to start the GrovePi starter kit
When I try to import pandas on macOS I get the error No module named'_bz2'
pip install --upgrade pip will result in No such file or directory
EC2 / Amazon Linux2: What to do if you get an "unable to execute'gcc': No such file or directory" error with pip install
Addressed "Python .h: No such file or directory" when installing uWSGI with Python 3.8
NO MORE “cd: foo: No such file or directory”
I want to get the path of the directory where the running file is stored.
I want to run the Python GUI when starting Raspberry Pi
When I run the exe file with pyinstaller, my PC crashes.
When I try to use pip, SSL module is not available.
-bash: ./ {file name} .sh: /usr/bin/bash: bad interpreter: No such file or directory
What to do when you get "I can't see the site !!!!"
A story about what to do when a bad interpreter: Not such file or directory appears in Anaconda3 and how to investigate the cause.
No such file or directory:'chromedriver': Resolve'chromedriver'
[Note] How to deal with unicode error and No such file or directory (output table to excel file with pandas)
When I tried to run Python, it was skipped to the Microsoft Store
Import Error: libffi.so.6: cannot open shared object file: No such file or directory
[Python] I tried to analyze the pitcher who achieved no hit no run
I get a Python No module named'encodings' error with the aws command
Cannot import cv2 (libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory)
fatal error: Python.h: no such files or directories when pip3 install psutil
When I try to connect django and postgresql with Docker, I get the error "django.db.utils.OperationalError: could not translate host name" db "to address: Name or service not known"
I tried to summarize the umask command
Get the path to the systemd unit file
I couldn't get out after upgrading pip
Try rewriting the file with the less command
When I name the file flask.py in Flask, I get Import Error: cannot import name'Flask'
I get a strange window when I use the open directory dialog in Tkinter
I want to get the file name, line number, and function name in Python 3.4
I want to be notified when the command operation is completed on linux!