Why pip saying import error after downgrading?

Question:

I downgraded pip to install some packages. but now pip is not working saying. my python version is 3.11.5 and used this command “sudo python -m pip install pip==18.0 –upgrade”. Here is the result for pip install <module_name>

I was expecting any solution for this issue as I tried reinstalling pip by condas and python. Nothing worked.

error code

Asked By: sandun herath

||

Answers:

It’s about using the proper environment.

If you are using conda environment, then while upgrading the pip, that environment should be selected, and while importing, the same should be selected in IDE also, same for CLI if you are running python in CLI.

Don’t use "sudo", if you are not using the python environment that came by default with the system.

Giving an example:

python -m pip install –upgrade pip

This should be your full command.

But make sure you are doing it in the proper environment.

A small hint for conda environments:

enter image description here

The conda environment selected will show you like this in your terminal in most cases (unless it’s not in environment variables).

And the same environment should be selected in your IDE while you are running your code. It should appear somewhere like this in your IDE (probably at the bottom right corner):

enter image description here

Answered By: Satyajeet Sahu
Answered By: sandun herath