I was trying to install a package which required an older version of pip and (stupidly) thought it would be a good idea to try installing the oldest version of pip possible (1.0).
To clarify, it is not pip 1.0.1 (which most guides I found on the internet refer to), but pip 1.0
When I attempt to run 'python -m pip install --upgrade pip', I get the following error:
C:\mydirectory\venv\Scripts\python.exe: No module named pip.__main__; 'pip' is a package and cannot be directly executed
When I run 'pip --version', I get the following info:
pip 1.0 from c:\mydirectory\venv\lib\site-packages (python 3.7)
Is there any way I can upgrade pip from this point?
python -m pip install -U pip should work. That is how I do it.
Try this:
python3 -m pip install pip
I have pip3 installed from when I installed Python3 through Homebrew. But now when I use pip3 to install things, I get the following message:
You are using pip version 10.0.1, however version 19.2.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
But when I use pip install --upgrade pip, I get the following message:
-bash: pip: command not found
I'm not sure what the precise terminology is, but should I be "linking" the pip command to pip3?
Upgrade pip3 as follows to avoid the confusion between pip and pip3:
python3 -m pip install --upgrade pip
This question has already been asked here, though there is no answer solving this problem.
pip upgrade fails inside virtual environment
The above question is duplicate and the references following answer:
gaierror: [Errno -2] Name or service not known
But this answer doesnot contain anything valid. The former answer also does not contain any helpful info!
My problem is exactly what is described in first link. I try upgrade pip from 10.0.1 to 18.1 but unable to. As a consequence I am unable to install Tensorflow. This Virtual environment is actually connected to pycharm and I am referencing it through command line. Here is the input and corresponding commandline output:
(venv) G:\Ashish\Tensorflow\venv\Scripts>pip install --upgrade pip
ERROR: To modify pip, please run the following command:
G:\Ashish\Tensorflow\venv\Scripts\python.exe -m pip install --upgrade pip
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
(venv) G:\Ashish\Tensorflow\venv\Scripts>G:\Ashish\Tensorflow\venv\Scripts\python.exe -m pip install --upgrade pip
Requirement already up-to-date: pip in g:\ashish\tensorflow\venv\lib\site-packages (18.1)
(venv) G:\Ashish\Tensorflow\venv\Scripts>pip --version
pip 10.0.1 from g:\ashish\tensorflow\venv\lib\site-packages\pip-10.0.1-py3.7.egg\pip (python 3.7)
(venv) G:\Ashish\Tensorflow\venv\Scripts>pip install --upgrade pip
ERROR: To modify pip, please run the following command:
G:\Ashish\Tensorflow\venv\Scripts\python.exe -m pip install --upgrade pip
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
(venv) G:\Ashish\Tensorflow\venv\Scripts>
I tried uninstalling the pip from virtual environment. I did not work. I am sorry if this is basic or involves basic knowledge about virtual env, This is my learning phase and some time before I can start to contribute to this awesome community.
Ok, solved the problem, thanks to suggestions of #hoefling and#Rahul Bhardwaj
For python environment showing 10.0.1 and 18.1:
pip in your virtual environment is 18.1 while the global pip is 10.0.1. So the issue is solved, simply upgrade global pip
For tensorflow not installing:
Install python 3.6
Add that to path
Create a virtual environment in pycharm using python 3.6
Install tensorflow
Done! Python 3.7 is yet to support tensorflow
What is the way to update a package using pip?
those do not work:
pip update
pip upgrade
I know this is a simple question but it is needed as it is not so easy to find (pip documentation doesn't pop up and other questions from stack overflow are relevant but are not exactly about that)
The way is
pip install <package_name> --upgrade
or in short
pip install <package_name> -U
Using sudo will ask to enter your root password to confirm the action, but although common, is considered unsafe.
If you do not have a root password (if you are not the admin) you should probably work with virtualenv.
You can also use the user flag to install it on this user only.
pip install <package_name> --upgrade --user
For a non-specific package and a more general solution, you can check out pip-review. A tool that checks what packages could/should be updated.
To install:
$ pip install pip-review
Then run:
$ pip-review --interactive
requests==0.14.0 is available (you have 0.13.2)
Upgrade now? [Y]es, [N]o, [A]ll, [Q]uit y
Use this code in terminal:
python -m pip install --upgrade PACKAGE_NAME
For example I want update pip package:
python -m pip install --upgrade pip
More examples:
python -m pip install --upgrade selenium
python -m pip install --upgrade requests
...
tl;dr script to update all installed packages
If you only want to upgrade one package, refer to #borgr's answer. I often find it necessary, or at least pleasing, to upgrade all my packages at once. Currently, pip doesn't natively support that action, but with sh scripting it is simple enough. You use pip list, awk (or cut and tail), and command substitution. My normal one-liner is:
for i in $(pip list -o | awk 'NR > 2 {print $1}'); do sudo pip install -U $i; done
This will ask for the root password. If you do not have access to that, the --user option of pip or virtualenv may be something to look into.
I use the following line to update all of my outdated packages:
pip list --outdated --format=freeze | awk -F '==' '{print $1}' | xargs -n1 pip install -U
import subprocess as sbp
import pip
pkgs = eval(str(sbp.run("pip3 list -o --format=json", shell=True,
stdout=sbp.PIPE).stdout, encoding='utf-8'))
for pkg in pkgs:
sbp.run("pip3 install --upgrade " + pkg['name'], shell=True)
Save as xx.py
Then run Python3 xx.py
Environment: python3.5+ pip10.0+
While off-topic, one may reach this question wishing to update pip itself (See here).
To upgrade pip for Python3.4+, you must use pip3 as follows:
sudo pip3 install pip --upgrade
This will upgrade pip located at: /usr/local/lib/python3.X/dist-packages
Otherwise, to upgrade pip for Python2.7, you would use pip as follows:
sudo pip install pip --upgrade
This will upgrade pip located at: /usr/local/lib/python2.7/dist-packages
Also, in Jupyter notebook, by running the code below in a code cell, you can update your package:
%pip install <package_name> --upgrade
Execute the below command in your command prompt,
C:\Users\Owner\AppData\Local\Programs\Python\Python310>python -m pip install --upgrade pip
Output will be like below,
Requirement already satisfied: pip in c:\users\owner\appdata\local\programs\python\python310\lib\site-packages (21.2.4)
Collecting pip
Downloading pip-22.0.3-py3-none-any.whl (2.1 MB)
|████████████████████████████████| 2.1 MB 3.3 MB/s
Installing collected packages: pip
Attempting uninstall: pip
Found existing installation: pip 21.2.4
Uninstalling pip-21.2.4:
Successfully uninstalled pip-21.2.4
Successfully installed pip-22.0.3
Im trying to install google assistant on my Raspberry Pi, but when I keep getting an error: pip is a package and cannot be directly executed
Instead of
pip [...]
Try doing
python -m pip [...]
Can't really help more without more info.
I think your version of pip is old. You need to upgrade it first, like this:
pip install -U pip
You may need to upgrade setuptools too:
pip install -U setuptools
Since google-assistant-library is available as a wheel, you need to install wheel too:
pip install wheel
I don't know if you can do that with Raspberry Pi, but I recommend you to used a virtualenv. That way, you have a fresh and isolated Python executable and a recent version of pip.
virtualenv your_proj
source your_proj/bin/activate
pip install wheel
pip install google-assistant-library
For newer version ie. using pip3:
pip3 install -U <<package name>>
I had the same problem.
I think it was an outcome of a failed
> .\python.exe -m pip install --upgrade pip
do to some environment misconfiguration.
So it first removed the existing version 10.0.1, and then the installation of the new version 22.3.1 failed, leaving me with no pip.
From official documentation, I ran
> .\python.exe -m ensurepip --upgrade
which restored the original pip 10.0.1.
Then I fixed the environment problem, and then again
> .\python.exe -m pip install --upgrade pip
I now have pip 22.3.1.