How can i upgrade pip using cmd? - pip

I want to upgrade pip, using cmd. But it doesn't.
Release was 19.0.3.
(There was an update on the latest version side like "setuptools" and i wanted to update to 19.3 using cmd but it didn't work and i did it manually.)
Maybe path can be wrong, so i shared paths.

pip is just a PyPI package so you can use it to upgrade itself.
pip install --upgrade pip
On Windows:
python -m pip install --upgrade pip

Related

How to upgrade pyenv (macOS) such that a fresh .venv contains an up-to-date pip?

I'm trying to prevent this warning every time I create a fresh .venv:
> /Users/pi/.pyenv/versions/3.10.0/bin/python -m venv .venv
> . .venv/bin/activate
> pip install ipykernel # or anything
WARNING: You are using pip version 21.2.3; however, version 22.2.2 is available.
You should consider upgrading via the '/Users/pi/code/foo/.venv/bin/python -m pip install --upgrade pip' command.
Somehow pyenv has populated my fresh .venv with an out-of-date pip.
If I execute the suggested command it will upgrade my .venv's pip. But I don't want to be doing that every time I create a .venv.
I figured this might fix it, but it doesn't:
> /Users/pi/.pyenv/versions/3.10.0/bin/python -m pip install --upgrade pip
Requirement already satisfied: pip in /Users/pi/.pyenv/versions/3.10.0/lib/python3.10/site-packages (22.2.1)
Collecting pip
Using cached pip-22.2.2-py3-none-any.whl (2.0 MB)
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 22.2.1
Uninstalling pip-22.2.1:
Successfully uninstalled pip-22.2.1
Successfully installed pip-22.2.2
What is actually happening when I execute the above command? I was expecting it to update the pip for the python version created/maintained by pyenv. Which it seems to be doing:
🧢 pi#pPro18-4 ~/.pyenv/versions/3.10.0
> find . -name 'pip*'
./bin/pip3
./bin/pip
./bin/pip3.10
./lib/python3.10/site-packages/pip
./lib/python3.10/site-packages/pip-22.2.2.dist-info
🧢 pi#pPro18-4 ~/.pyenv/versions/3.10.0
> ./bin/pip --version
pip 22.2.2 from /Users/pi/.pyenv/versions/3.10.0/lib/python3.10/site-packages/pip (python 3.10)
So why isn't this pip getting copied into my .venv when I create it?
I thought that was the way .venv creation worked.
How to clean up my pyenv Python installation so that it spawns up-to-date .venvs?
EDIT:
Insight from #python on IRC/Libera:
grym: I don't think you can; i just get in the habit of python -m venv somevenv && somevenv/bin/python -m pip install --upgrade pip setuptools wheel
jinsun: python -m venv --upgrade-deps .venv is a simple solution if you were just annoying by the pip warning (...) it is updating the pip inside the venv, forget about the base python, I don't even have pip in the base python
This is the use case for pyenv-hooks
pyenv-hooks are scripts that are executed by pyenv whenever certain commands are run. You can create hooks for regular commands like: exec, rehash, which, but it can also be a plugin command, like virtualenv. The scripts can be written in any language.
Here is the wiki with official instructions.
You can have a hook by creating a script at the following location:
$PYENV_ROOT/pyenv.d/<hook-name>/<your-script-name>
For example, to create a hook that upgrades pip, create a new script within this path:
$PYENV_ROOT/pyenv.d/virtualenv/after.bash
With contents:
after_virtualenv 'PYENV_VERSION="$VIRTUALENV_NAME" pyenv-exec pip install --upgrade pip'
after_virtualenv is the command that tells pyenv when to execute. First, it sets the pyenv version to the name of the virtualenv we just created. with the variable $VIRTUALENV_NAME. Then it upgrades pip itself.
More details in this article.
I originally posted it as a comment, but was suggested to make it a proper answer.
An easier approach is to use the upgrade-deps flag when you create a virtual environment. Like this:
python3 -m venv --upgrade-deps .venv
It was added on python3.9, and according to the official docs:
--upgrade-deps
Upgrade core dependencies (pip, setuptools) to the latest version in PyPI
So, in other words, it will install pip and upgrade right away.

How to avoid pip install package again while conda install was done before?

guys:
I use conda install tensorflow-gputo install tensorflow 2.0 , and
numpy=1.20.2 would be one of the package installed, and then I use python3 -m pip install SOMEPACKAGE ,this SOMEPACKAGE needs numpy to be installed as well , but pip seems does not check or realize the package numpy has already installed...
I would like to show everything I know so far :
1.I know the packages installed via conda install would go to anaconda3/envs/YOUR_ENV/lib/site-packages
2.I use python3 -m pip install -t anaconda3/envs/YOUR_ENV/lib/site-packages to force the package would be installed to the place where conda install would be.
However,pip still tries to dwonload *.whl file and install package again,I do not want this package installation process happen again ,while it did mention that I can use --upgrade to replace the existed package...
So I would like to know
How does pip and conda install check if the target package has already existed before they actually to through install process?
I think using python3 you are not using interpreter from your current conda environment so it gets installed elsewhere
python -m pip install (or simply pip install) from your activated environment should work and ignore dependencies installed by conda if they satisfy the requirements

even after using pip update command, the version remains the same

I was just trying to download packages using pip in the terminal in pycharm and there was a notice from pip saying "You are using pip version 10.0.1, however, version 19.3.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command."
I ran the command but when I typed "pip -V" to check the version, it remained the same 10.0.1. And when I run the command, it says that pip is already up to date
How can solve this?
Your python and pip seem to point to different python versions. Check by typing which python or where python in the terminal.
To make sure they match, you can use
python -m pip install --upgrade pip (as you did) for upgrading
python -m pip install <package name> for installation

How to uninstall Airflow?

I am a newbie to Airflow. i have some trouble to remove Airflow v1.10.3 ,i am using pip3 version 8.1.1 on Ubuntu 16.04.
I already tried to remove pip with sudo apt-get remove python3-pip
and sudo apt-get remove pip3 and all his dependencies.
and tried to remove all libraries related with Python.
But i stil have Airflow and his commands down in terminal.
If you are not able to uninstall with
pip uninstall airflow
Maybe the reason is for the latest versions of Airflow this command will work
pip uninstall apache-airflow
Credits to This Answer.
The command apt-get remove pip doesn't remove pip-installed libraries.To uninstall pip-installed libraries you need to install pip back and then uninstall the libraries using pip:
sudo apt install pip # or pip3
pip uninstall airflow
or
pip3 uninstall airflow
depending on what python version you use.

Tensorflow installation on Windows 10, error 'Not a supported wheel on this platform'

This question is for a Windows 10 laptop. I'm currently trying to install tensorflow, however, when I run:
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.0-cp35-cp35m-win_x86_64.whl
I get the following error:
tensorflow-1.0.0-cp35-cp35m-win_x86_64.whl is not a supported wheel on this platform.
I am trying to install the cpu-version only of tensorflow in an Anaconda 4.3.0 version. I had python 3.6.0 and then I downgraded to 3.5.0, none of them worked.
I also had same problem when I installed anaconda 4.3 version
Here is my solution.
Instead of using Anaconda3 4.3, install Anaconda3 4.2(Anaconda3-4.2.0-Windows-x86_64.exe)
Type on command line(If you are using GPU version)
pip install -U --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/gpu/tensorflow_gpu-1.0.0-cp35-cp35m-win_amd64.whl
Typeon command line(If you are using CPU only)
pip install -U --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.0.0-cp35-cp35m-win_amd64.whl
I'm working on win10 with python version=3.5.2, 64 bit
You can use same version of anaconda and execute this command
conda create -n tensorflow python=3.5
activate tensorflow
pip install tensorflow-gpu
It worked for conda 4.0.8
So are you sure you correctly downgraded your python? Run this command on command line pip -V. This should print the pip version and the python version.
Inside your Anaconda environment, try running this:
pip install --upgrade tensorflow
This will do the job. The issue was discussed here also.
Here is the screenshot of how this helped me:
If you have python3 on Windows insatalled, you can use the following command(non GPU):
pip install --upgrade https://storage.googleapis.com/tensorflow/mac/cpu/tensorflow-0.10.0-py3-none-any.whl
Worked for me.

Resources