How to remove packages installed with older versions of Python/Pip? - python

I'm experiencing a issue with my packages, I installed a package with Python 3.7 and the current version of Python in my computer is 3.9. So I can't uninstall or update the given package.
ζ pip3 install --upgrade youtube-dl
Requirement already satisfied: youtube-dl in /usr/local/lib/python3.9/site-packages (2021.4.7)
Collecting youtube-dl
Downloading youtube_dl-2021.4.26-py2.py3-none-any.whl (1.9 MB)
|████████████████████████████████| 1.9 MB 551 kB/s
Installing collected packages: youtube-dl
Attempting uninstall: youtube-dl
Found existing installation: youtube-dl 2021.4.7
Uninstalling youtube-dl-2021.4.7:
Successfully uninstalled youtube-dl-2021.4.7
Successfully installed youtube-dl-2021.4.26
WARNING: You are using pip version 21.0.1; however, version 21.1.1 is available.
You should consider upgrading via the '/usr/local/opt/python#3.9/bin/python3.9 -m pip install --upgrade pip' command.
ζ youtube-dl --version
2021.04.01
ζ which pip3
/usr/local/opt/python#3.9/bin/pip3
ζ which youtube-dl
/Library/Frameworks/Python.framework/Versions/3.7/bin/youtube-dl
How can

What you need to do to solve this issue is navigate to the Pip from the version that you have installed the package, in this case, 3.7, uninstall or update the package using this pip.
ζ cd /Library/Frameworks/Python.framework/Versions/3.7/bin/
ζ ./pip3 uninstall youtube-dl
Found existing installation: youtube-dl 2021.4.1
Uninstalling youtube-dl-2021.4.1:
Would remove:
/Library/Frameworks/Python.framework/Versions/3.7/bin/youtube-dl
/Library/Frameworks/Python.framework/Versions/3.7/etc/bash_completion.d/youtube-dl.bash-completion
/Library/Frameworks/Python.framework/Versions/3.7/etc/fish/completions/youtube-dl.fish
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/youtube_dl-2021.4.1.dist-info/*
/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/youtube_dl/*
/Library/Frameworks/Python.framework/Versions/3.7/share/doc/youtube_dl/README.txt
/Library/Frameworks/Python.framework/Versions/3.7/share/man/man1/youtube-dl.1
Proceed (y/n)? y
Successfully uninstalled youtube-dl-2021.4.1
Now you can install the package with latest the Python in your system
ζ pip3 install youtube-dl
This answer also provide a method for dealing with multiple python versions

well and if you are looking to install the latest pip version with the help of pip, just runpython3 -m pip install pip=="VERSION_NUMBER_HERE" for a precise pip installation

Related

windows - pip will not update, install completes successfully but version never changes

I was tired of seeing the warning so figured I'd update pip from 21.0.1 to 21.1.2, however, when using the command D:\Python38\python.exe -m pip install --upgrade pip, or python -m pip install --upgrade pip, the version never changes to 21.1.2. I have restarted my terminal, I have checked my path, the only thing I can think is that I changed the global.cache dir to my D: drive to conserve space on my windows hog of a machine. Here is a snippet from my terminal of what I have going on.
D:\>python -V
Python 3.8.8
D:\>pip -V
pip 21.0.1 from d:\python38\lib\site-packages\pip (python 3.8)
D:\>python -m pip install --upgrade pip
Collecting pip
Using cached pip-21.1.2-py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Successfully installed pip-21.1.2
WARNING: You are using pip version 21.0.1; however, version 21.1.2 is available.
You should consider upgrading via the 'D:\Python38\python.exe -m pip install --upgrade pip' command.
D:\>pip -V
pip 21.0.1 from d:\python38\lib\site-packages\pip (python 3.8)
D:\>python -m pip install --upgrade --no-cache pip
Collecting pip
Downloading pip-21.1.2-py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 939 kB/s
Installing collected packages: pip
Successfully installed pip-21.1.2
WARNING: You are using pip version 21.0.1; however, version 21.1.2 is available.
You should consider upgrading via the 'D:\Python38\python.exe -m pip install --upgrade pip' command.
D:\>pip -V
pip 21.0.1 from d:\python38\lib\site-packages\pip (python 3.8)
my pip config debug info:
D:\>pip config debug
env_var:
env:
global:
C:\ProgramData\pip\pip.ini, exists: False
site:
d:\python38\pip.ini, exists: False
user:
C:\Users\logan\pip\pip.ini, exists: False
C:\Users\logan\AppData\Roaming\pip\pip.ini, exists: True
global.target: D:\Git\pip\site-packages
global.cache: D:\Git\pip\cache
global.pip-cache-dir: D:\Git\pip\cache
I have scoured the internet for an inkling into why this is happening but I can't seem to find an answer. Thing is, this isn't something that I have to have done, it's just nagging at me that I cant figure it out at this point.
I have read through the pip documentation config file and user guide and of course I have looked for my answer here before asking my question, I hope someone out there can give me some insight and thank you for your time.

Python 3 is not upgrading pip. Am I linking a wrong directory?

I have the following issue every time I try to install a package in Python 3:
WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command
I tried to do the upgrade pip command as follows, with the also following warning:
$ pip3 install --upgrade pip
Collecting pip
Using cached pip-20.3.1-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Successfully installed pip-20.3.1
WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command
I tried the other way, with the same error:
$ /usr/bin/python3 -m pip install --upgrade pip
Collecting pip
Using cached pip-20.3.1-py2.py3-none-any.whl (1.5 MB)
Installing collected packages: pip
Successfully installed pip-20.3.1
WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command
I also tried the Following suggestion to solve this problem, downloading the package and ask pip to install directly from the .tar.gz file:
$sudo python3 -m pip install /home/me/Downloads/pip-20.3.1.tar.gz
[sudo] password for me:
Processing /home/me/Downloads/pip-20.3.1.tar.gz
Installing build dependencies ... done
Getting requirements to build wheel ... done
Preparing wheel metadata ... done
Building wheels for collected packages: pip
Building wheel for pip (PEP 517) ... done
Created wheel for pip: filename=pip-20.3.1-py2.py3-none-any.whl size=1518515 sha256=36207044a2b9042728f3cd0f971569217f4e2e9c68c84adbf5c42617e08b9d3c
Stored in directory: /root/.cache/pip/wheels/0e/09/b2/4673e6d2eee911dbbeaeeba8e68eebb9719b1b3ba25ad93e2c
Successfully built pip
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.0.2
Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-20.3.1
Again, the same error happens:
$pip3 install pydot
Collecting pydot
Using cached pydot-1.4.1-py2.py3-none-any.whl (19 kB)
Collecting pyparsing>=2.1.4
Using cached pyparsing-2.4.7-py2.py3-none-any.whl (67 kB)
Installing collected packages: pyparsing, pydot
Successfully installed pydot-1.4.1 pyparsing-2.4.7
WARNING: You are using pip version 20.2.4; however, version 20.3.1 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.
My Python versions are:
$python --version
Python 3.7.9
$python3 --version
Python 3.8.5
My PATH variable links the following directories:
$echo $PATH
/home/me/.local/bin:/home/me/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
What is happening here? should I have to add something to my PATH variable in order to link the right python version to the pip upgrade command? or there is something else to be done?
Just do the pip3 upgrade with sudo. I think you mixed up python2 and python3 installs with your sudo call.
Just tested and gave me the correct version on pip3:
$ sudo pip3 install --upgrade pip
Collecting pip
Downloading pip-20.3.1-py2.py3-none-any.whl (1.5 MB)
|████████████████████████████████| 1.5 MB 2.6 MB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 20.0.2
Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-20.3.1
$ pip3 --version
pip 20.3.1 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
Tested on KDE Neon (Ubuntu 20.04).
Also make sure you don't have another version of pip installed somewhere in the user installations. These easily get mixed up between apt and the user locations for python installs.
pip install --upgrade pip --no-cache-dir
This worked for me
You are using pip version 19.2.3, however version 20.3.4 is available.
You should consider upgrading via the pip install --upgrade pip command.

Installing opencv on Ubuntu 16-04

I have a virtualenv created with virtualenvwrapper.
However, I'm on python 2.7
Whenever I try to install the opencv-python by pip, as sudo or not, I receive this message:
pip install opencv-python
Downloading/unpacking opencv-python
Could not find any downloads that satisfy the requirement opencv-python
Cleaning up...
No distributions at all found for opencv-python
Storing debug log for failure in /home/kristian/.pip/pip.log
Any ideas on why this us happening?
Your pip is most likely too old since opencv-python packages are distributed as manylinux1 wheels (https://github.com/pypa/manylinux). You need pip version 8.1 or later to install manylinux1 binary packages.
To upgrade your pip globally:
sudo -H pip install --upgrade pip
Inside virtualenv this should be enough:
pip install --upgrade pip
I recommend you to use anaconda, which is very convenient and saves a lot of trouble. With anaconda, you don't need to care about your local environment.

Pip updates but installs old version

$ pip install -U pip
Collecting pip
Using cached pip-9.0.1-py2.py3-none-any.whl
Installing collected packages: pip
Successfully installed pip-8.1.1
You are using pip version 8.1.1, however version 9.0.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
The problem is pretty self-explanatory.
I tell pip to update itself, it gets the 9.0.1 package, installs 8.1.1 somehow then tells me to run the command i just ran to update it.
I managed to fix it by installing pip trough the script given at the website(apt-get installs version 8.1.1):
https://bootstrap.pypa.io/get-pip.py
It automatically uninstalled the old version so everything is in order now.

How to downgrade the installed version of 'pip' on windows?

On a windows 7 machine I have pip version 1.5.6 installed:
pip 1.5.6 from C:\Users\dietz\PNC\tas\ENV\lib\site-packages (python 2.7)
In order to find the reason for an error I want to install a different version of pip, which worked fine for me. So how can I uninstall pip and install version 1.2.1 instead?
pip itself is just a normal python package. Thus you can install pip with pip.
Of cource, you don't want to affect the system's pip, install it inside a virtualenv.
pip install pip==1.2.1
If downgrading from pip version 10 because of PyCharm manage.py or other python errors:
python -m pip install pip==9.0.1
If you want to upgrade or downgrade to different version of pip, better use --upgrade option at one go instead doing it in two steps. i.e. first uninstalling the existing and then re-installing to new version, below does both in one go as shown below.
USE: Executed on WIN10 with Bash
python -m pip install --upgrade pip==19.2.3
$ python -m pip install --upgrade pip==19.2.3
Collecting pip==19.2.3
Using cached pip-19.2.3-py2.py3-none-any.whl (1.4 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 21.3.1
Uninstalling pip-21.3.1:
Successfully uninstalled pip-21.3.1
Successfully installed pip-19.2.3
well the only thing that will work is
python -m pip install pip==
you can and should run it under IDE terminal (mine was pycharm)
If you have to downgrade pip version do following steps:
step1. pip uninstall pip
step2. pip install pip==version number you want to install or downgrade
step3. check version of pip using pip --version
This process also works when any other package giving error exit code(2) you can follow these steps and install your package.

Categories

Resources