pip is a package and cannot be directly executed - python

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.

Related

How do I upgrade from pip 1.0?

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

pip freeze gives different version from pip --version

I am on Windows 10 and just installed Python 3.7.4. I installed virtualenv using pip install virtualenv, and i got the message that i installed 16.7.2 while 19.2.1 is available. I then used python -m pip install --upgrade pip to upgrade.
Here is the issue: when i type pip freeze on Powershell, i am getting this:
virtualenv==16.7.2
but when i type pip --version, i am getting this:
pip 19.2.1 from c:\users\user1\python\lib\site-packages\pip (python 3.7)
Can you please let me know why pip freeze still shows the old version?
Thanks.
pip and virtualenv are 2 different cases where pip is mainly used for installing python packages and virtualenv for utilizing virtual environments while development.
The following command updates only pip not virtual env
python -m pip install --upgrade pip
If you think you still need to upgrade virtualenv (of course if a new version is available). Please follow the following syntax without specifying a version.
pip install [package] --upgrade

Upgrading pip for different versions of python

I have two versions of python installed on my computer (3.6 and 3.7). Just upgraded pip to the latest version (19.0.1) using the command python -m pip install --upgrade pip however i think it only upgraded the pip for python version 3.6. When attempting to install a package specifically for python version 3.7 with the following command pip3.7 install scipy i got the message saying You are using pip version 18.1, however version 19.0.1 is available. Clearly only the pip for version 3.6 was upgraded. I cannot figure out a command to upgrade 3.7 pip as well. I tried the following:
python -m pip3.7 install --upgrade pip
This did not work (Trying to use the logic of how packages are handled for different versions of python). Could not find a question that addressed this specific issue. Any help would be greatly appreciated.
Use the python 3.7 interpreter to run the command:
python3.7 -m pip install --upgrade pip
Or use the pip3.7 binary directly:
pip3.7 install --upgrade pip
export LD_LIBRARY_PATH=/usr/lib64
activate pip3
I ran into the same problem. If you have Microsoft Visual also installed the best command to use is
py -m pip install --upgrade pip --user
I used that command, and it worked like a charm.

pip install -U setuptools fail windows 10

I just installed Python3.7 and Pycharm on my Windows 10 PC.
I am running pip version 9.0.2
In Pycharm, it says I have version 28.8.0 of setuptools, when I try to upgrade this in Pycharm, which I believe runs the line
pip install -U setuptools
I get the error:
PermissionError: [WinError 32] The process cannot access the file because it
is being used by another process:
'c:\users\Username\pycharmprojects\untitled1\venv\lib\site-
packages\setuptools-28.8.0-py3.6.egg' ->
'C:\Users\Username\AppData\Local\Temp\pip-i5jxitem-
uninstall\users\Username\pycharmprojects\untitled1\venv\lib\site-
packages\setuptools-28.8.0-py3.6.egg'
I have tried running
pip install --upgrade setuptools
which runs successfully and says I have the latest version.
Does anyone know how I can successfully update setuptools?
The reason I'd like setuptools to be up to date, is so I can then get rid of the egg_info error installing other packages.
I have the same error. Not sure why it happened. But I managed to upgrade by running:
pip install setuptools --upgrade --ignore-installed
You can also try:
easy_install --upgrade setuptools
Even though easy_install's deprecated, there's a good chance it'll still work on Windows.
If you try to use pip to upgrade setuptools:
pip install -U setuptools
it seems to get stuck on an error about 10.0 vs 18.0 "You should consider upgrading via the 'python -m pip install --upgrade pip' command."
The official pip doco(https://pip.pypa.io/en/stable/installing/#upgrading-pip) says on Windows to use this:
python -m pip install --upgrade pip
However, it seemed pip and setuptools had a hiccup with a circular dependency or lock around pip-v9.0 or 10.0 to pip-18.0 and setuptools v28.0 to v39.0 or 40.0 so persevere with this:
python -m pip install --force-reinstall pip
You need setuptools >= 39.0 if you want to install pipenv also.
Try the following command to upgrade the setup tools in windows
pip install -U pip setuptools
or
pip install setuptools --upgrade --ignore-installed
I solved more or less similar problem as follow:
In my PyCharm project terminal tab:
`(venv) PS C:/path/to/project>`
updated pip, setup tools and wheels with command:
py -m pip install --upgrade pip setuptools wheel
(source of recommendation)

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