How to break recursive error when updating PIP - python

I'm trying to update PIP (the Python package installer) so I can install a package in Python, but in order to do so, I need to use a PIP command. Essentially, I can't update PIP without having PIP been updated (i.e the command is python -m pip install --upgrade pip).
The error message is get is:
You are using pip version 9.0.1, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
In addition, the packages that I am attempting to install do not install.
I'm unsure how to get around this problem, and would greatly appreciate some help.

Just try it with administration privileges.
sudo python -m pip install --upgrade pip
*** If you are using windows run the command prompt as the administration

Related

You are using pip version 8.1.1, however version 21.2.3 is available. You should consider upgrading via the 'pip install --upgrade pip' command

I am trying to get started with python on VS Code but I keep getting this error when I want to install the matplotlib library.
Consider using the --user option or check the permissions.
pip install -U --upgrade pip
I tried a lot of different ones but the one below worked for me
pip3 install --upgrade pip --user
Three things to do:
Run this in your bash terminal
python3 pip install --upgrade pip
Configure your VS Code environment for python 3.x
Run your file using python3 [filename.py]
If the above suggestion fails, you should try:
pip install --upgrade pip
I added the folder than tried pip install --upgrade pip and it worked. You may have to show your hidden folders to follow the path.
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases. To fix this problem, I'm trying to install it using this command:
python -m pip install --upgrade pip setuptools virtualenv)

Unable to install a Python package

Whenever I try to install the SpeechRecognition package within my Python environment it keeps telling me You are using pip version 10.0.1, however version 20.3.3 is available. You should consider upgrading via the 'python -m pip install --upgrade pip' command., However, when I check the pip version I can see that it's on the latest version. The package doesn't install and continues to show this message.
Also just an off question, what does the -m wildcard do for the pip install command?
Any ideas?
Thanks in advance,
-Yaseen
Try to upgrade the pip using this command:
python -m pip install --upgrade pip

Environment Error [Errno 2] while installing pip packages or upgrading pip

pip used to work fine until recently. First I was trying to install a pip-package using
pip install -e [some-git-link]
and I get the error
Could not install packages due to an EnvironmentError: [Errno 2] No such file or directory: '/home/me/.local/lib/python2.7/site-packages/pip-19.0.1.dist-info/METADATA'
I then cd'ed into site-packages and the folder is empty. Indeed, I have pip installed in dis-packages and its version is 18.1, not 19.0!
I tried to update pip through
pip install -U pip
but I get the same error.
Typing
pip --version
I get
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/init.py:83: RequestsDependencyWarning: Old version of cryptography ([1, 2, 3]) may cause slowdown.
warnings.warn(warning, RequestsDependencyWarning)
pip 18.1 from /usr/local/lib/python2.7/dist-packages/pip (python 2.7)
so it seems that pip 18.1 is installed. Indeed, if I try
sudo apt-get install python-pip
I get
python-pip is already the newest version (8.1.1-2ubuntu0.4).
0 upgraded, 0 newly installed, 0 to remove and 62 not upgraded.
I was wondering if all these problems were coming from the warning on the cryptography, and so I tried to do
sudo pip install --upgrade cryptography
but obviously I go back to the same Environment Error.
Thou shalt not use sudo with pip. Using sudo with pip is asking for trouble. When you do that you are having pip and your OS's package manager get into a fight. When they fight no one wins, least of all your Python installation and personal sanity. I know countless tutorials tell you to sudo pip install, but they are not your friends. The only safe and reliable way to maintain a functional Python installation is to let your OS's package manager manage what it wants to manage and either use pip install --user or virtual environments (using either virtualenv or optionally python -m venv if you're on Python 3).
I really can't stress enough that you will constantly be running into little weird things (and occasional catastrophic problems) within your Python installation if you persistently sudo install things. Learn to love virtual environments! You can even modify your shell's PATH so that things you install in an environment are available as commands (which is commonly why people think they need sudo pip install).
You could test to update PythonOpenSSL :
$ sudo python -m easy_install --upgrade pyOpenSSL
If not Ok, please do :
$ sudo pip install --upgrade cryptography
But error with : $ sudo pip
So do after :
$ sudo python -m easy_install --upgrade pyOpenSSL
Have Fun,
Johan MRe
I was getting this error trying to install packages while building a Docker image (with python:3.8 as base). Upgrading pyOpenSSL as #Johan MRe suggested solved it for me.
RUN python3 -m easy_install --upgrade pyOpenSSL
How to deal with "Could not install packages due to an EnvironmentError" when upgrade pip
First run command line in Administration mode both window and OS:
Next,
For windows: use this command to upgrade pip
python -m pip install --user --upgrade pip
For MacOS:
sudo python -m pip install --user --upgrade pip

Cannot update pip on ubuntu

I am trying to update pip on ubuntu because it keeps telling me "You are using pip version 8.1.1, however version 8.1.2 is available.
You should consider upgrading via the 'pip install --upgrade pip' command." but when I use that command it tells me "bash: /home/zak/.local/bin/pip: /usr/bin/python: bad interpreter: No such file or directory"
If you are updating it globally (and not inside a virtualbox) try using sudo.
sudo pip install --upgrade pip

How do I update/upgrade pip itself from inside my virtual environment?

I'm able to update pip-managed packages, but how do I update pip itself? According to pip --version, I currently have pip 1.1 installed in my virtualenv and I want to update to the latest version.
What's the command for that? Do I need to use distribute or is there a native pip or virtualenv command? I've already tried pip update and pip update pip with no success.
pip is just a PyPI package like any other; you could use it to upgrade itself the same way you would upgrade any package:
pip install --upgrade pip
On Windows the recommended command is:
python -m pip install --upgrade pip
The more safe method is to run pip though a python module:
python -m pip install -U pip
On windows there seem to be a problem with binaries that try to replace themselves, this method works around that limitation.
In my case my pip version was broken so the update by itself would not work.
Fix:
(inside virtualenv):easy_install -U pip
I tried all of these solutions mentioned above under Debian Jessie. They don't work, because it just takes the latest version compile by the debian package manager which is 1.5.6 which equates to version 6.0.x. Some packages that use pip as prerequisites will not work as a results, such as spaCy (which needs the option --no-cache-dir to function correctly).
So the actual best way to solve these problems is to run get-pip.py downloaded using wget, from the website or using curl as follows:
wget https://bootstrap.pypa.io/get-pip.py -O ./get-pip.py
python ./get-pip.py
python3 ./get-pip.py
This will install the current version which at the time of writing this solution is 9.0.1 which is way beyond what Debian provides.
$ pip --version
pip 9.0.1 from /home/myhomedir/myvirtualenvdir/lib/python2.7/dist-packages (python 2.7)
$ pip3 --version
pip 9.0.1 from /home/myhomedir/myvirtualenvdir/lib/python3.4/site-packages (python 3.4)
In case you are using venv any update to pip install will result in upgrading the system pip instead of the venv pip. You need to upgrade the pip bootstrapping packages as well.
python3 -m pip install --upgrade pip setuptools wheel
for windows,
go to command prompt
and use this command
python -m pip install -–upgrade pip
Dont forget to restart the editor,to avoid any error
you can check the version of the pip by
pip --version
if you want to install any particular version of pip , for example version 18.1 then use this command,
python -m pip install pip==18.1
pip install --upgrade pip
In UBUNTU 18.04 I got the following error when I execute the above command:
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/bin/pip'
Consider using the `--user` option or check the permissions.
The below command solves my problem:
pip install --upgrade pip --user
Upgrading pip using 'pip install --upgrade pip' does not always work because of the dreaded cert issue: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version
I like to use the one line command for virtual envs:
curl https://bootstrap.pypa.io/get-pip.py | python -
Or if you want to install it box wide you will need
curl https://bootstrap.pypa.io/get-pip.py | sudo python -
you can give curl a -s flag if you want to silence the output when running in an automation script.
To get this to work for me I had to drill down in the Python directory using the Python command prompt (on WIN10 from VS CODE). In my case it was in my AppData\Local\Programs\Python\python35-32 directory. From there now I ran the command...
python -m pip install --upgrade pip
This worked and I'm good to go.
For linux
python3 -m pip install --upgrade pip
For windows:
Type Command Prompt in the Windows search box
In the Command Prompt, type cd\
Press Enter, and you’ll see the drive name C:\>
Locate your Python application path, which is the folder where you originally installed Python
Here is an example of a Python application path:
C:\Users\Ron\AppData\Local\Programs\Python\Python39
Once you retrieved the Python application path, type the following command in the Command Prompt:
cd followed by your Python application path
For our example:
C:\>cd C:\Users\Ron\AppData\Local\Programs\Python\Python39
Press Enter
Type python -m pip install --upgrade pip and press Enter
In my case this worked from the terminal command line in Debian Stable
python3 -m pip install --upgrade pip
Open Command Prompt with Administrator Permissions, and repeat the command:
python -m pip install --upgrade pip
pip version 10 has an issue. It will manifest as the error:
ubuntu#mymachine-:~/mydir$ sudo pip install --upgrade pip
Traceback (most recent call last):
File "/usr/bin/pip", line 9, in <module>
from pip import main
ImportError: cannot import name main
The solution is to be in the venv you want to upgrade and then run:
sudo myvenv/bin/pip install --upgrade pip
rather than just
sudo pip install --upgrade pip
I was in a similar situation and wanted to update urllib3 package.
What worked for me was:
pip3 install --upgrade --force-reinstall --ignore-installed urllib3==1.25.3
On my lap-top with Windows 7 the right way to install latest version of pip is:
python.exe -m pip install --upgrade pip
First, do this:
sudo apt install python3-pip python-setuptools-doc
Then, as a non-root user (NEVER, never run pip* as root!):
# N.B. bash shell works for this, I have never tested with other shells!
. ....your_virtualenv_folder/bin/activate
pip3 install -U pip
Note: -U is a synonym for --upgrade, as far as I know.
I had installed Python in C:\Python\Python36 so I went to the Windows command prompt and typed cd C:\Python\Python36 to get to the right directory. Then entered the python -m install --upgrade pip all good!
Single Line Python Program
The best way I have found is to write a single line program that downloads and runs the official get-pip script. See below for the code.
The official docs recommend using curl to download the get-pip script, but since I work on windows and don't have curl installed I prefer using python itself to download and run the script.
Here is the single line program that can be run via the command line using Python 3:
python -c "import urllib.request; exec(urllib.request.urlopen('https://bootstrap.pypa.io/get-pip.py').read())"
This line gets the official "get-pip.py" script as per the installation notes and executes the script with the "exec" command.
For Python2 you would replace "urllib.request" with "urllib2":
python -c "import urllib2; exec(urllib2.urlopen('https://bootstrap.pypa.io/get-pip.py').read())"
Precautions
It's worth noting that running any python script blindly is inherently dangerous. For this reason, the official instructions recommend downloading the script and inspecting it before running.
That said, many people don't actually inspect the code and just run it. This one-line program makes that easier.
I had a similar problem on a raspberry pi.
The problem was that http requires SSL and so I needed to force it to use https to get around this requirement.
sudo pip install --upgrade pip --index-url=https://pypi.python.org/simple
or
sudo pip-3.2 --upgrade pip --index-url=https://pypi.python.org/simple/
Head to your command prompt and type the following:
python -m pip install --upgrade pip
While updating pip in virtual env use full path in python command
Envirnments folder struture
myenv\scripts\python
h:\folderName\myenv\scripts\python -m pip install --upgrade pip
Very Simple. Just download pip from https://bootstrap.pypa.io/get-pip.py . Save the file in some forlder or dekstop. I saved the file in my D drive.Then from your command prompt navigate to the folder where you have downloaded pip. Then type there
python -get-pip.py
In linux
I will update with this code
sudo -H pip3 install --upgrade pip

Categories