Search code examples
pythonpippycharm

Path to pip broken - pip : The term 'pip' is not recognized as the name of a cmdlet,


if i do this from terminal in PyCharm just try to install the package with pip.

(venv) PS C:\Development\Citizenship\video_auto_generator> pip install python-dotenv                            

I get

pip : The term 'pip' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:1

  • pip install python-dotenv
  • + CategoryInfo          : ObjectNotFound: (pip:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException
    

However if i do

(venv) PS C:\Development\Citizenship\video_auto_generator> venv\Scripts\python.exe -m pip install python-dotenv

and supply the path to python in the venv directory. it works.

Collecting python-dotenv Using cached python_dotenv-1.0.1-py3-none-any.whl.metadata (23 kB) Using cached python_dotenv-1.0.1-py3-none-any.whl (19 kB) Installing collected packages: python-dotenv Successfully installed python-dotenv-1.0.1

This works in another project i have but its broken in my new project.

Python 3.12. Im having so many issues with this since upgrading to 3.12 i cant get a new project crated that works out of the box with venv it takes forever to debug issues.

This also works

py -m pip install python-dotenv

Why cant i just type pip install like i used to.

update

"C:\Program Files\Python312\python.exe" -m venv venv
.\venv\Scripts\activate

which give me invalid interpreter in pycharm and then i try to feed it the path to python and i get

Error: Python packaging tool 'setuptools' not found

if i try to then create a new venv via pycharm i get pip :

The term 'pip' is not recognized as the name of a cmdlet

i suspect this is something silly but i cant get anything to work now and its a big problem.

even

py -m pip list 

on some of my projects fails that it cant find pip

enter image description here

update 2

If i create a new project it works fine

"C:\Program Files\Python312\python.exe" -m venv venv
.\venv\Scripts\activate
echo python-dotenv > requirements.txt
type nul > .env
type nul > app.py
type nul > README.MD
pip install -r requirements.txt
pip list

However if i do this in an existing project.

"C:\Program Files\Python312\python.exe" -m venv venv
.\venv\Scripts\activate

and try to use that in PyCharm I get. how can it be invalid.

enter image description here


Solution

  • it seems that distutils was deprecated in python version 3.10 so the venv creation doesn't include it. which calls the project to fail.

    this fixes it.

    pip install setuptools