not able to run pip in python3 venv (OS : Ubuntu 22.04.1 LTS)

588 views Asked by At

I created python virtual env using below command

python3 -m venv env

But I am not able to run pip inside it to install dependencies, can someone please help, though I can see pip present inside bin

(env) u@u-Lenovo-ideapad-520-15IKB:~/Documents/github/CarPartsDetectionChallenge_v3p/env/bin$ ls -lart
    total 44
    drwxrwxr-x 5 s s 4096 Jan 11 08:49 ..
    lrwxrwxrwx 1 s s    7 Jan 11 08:49 python3.10 -> python3
    lrwxrwxrwx 1 s s   16 Jan 11 08:49 python3 -> /usr/bin/python3
    lrwxrwxrwx 1 s s    7 Jan 11 08:49 python -> python3
    -rwxrwxr-x 1 s s  284 Jan 11 08:50 pip3.10
    -rwxrwxr-x 1 s s  284 Jan 11 08:50 pip3
    -rwxrwxr-x 1 s s  284 Jan 11 08:50 pip
    -rw-r--r-- 1 s s 9033 Jan 11 08:50 Activate.ps1
    -rw-r--r-- 1 s s 2100 Jan 11 08:50 activate.fish
    -rw-r--r-- 1 s s  958 Jan 11 08:50 activate.csh
    -rw-r--r-- 1 s s 2032 Jan 11 08:50 activate
    drwxrwxr-x 2 s s 4096 Jan 11 08:50 .
    (env) s@s-Lenovo-ideapad-520-15IKB:~/Documents/github/CarPartsDetectionChallenge_v3p/env/bin$ python3 -m pip install -r requirements.txt
    /home/s/Documents/github/CarPartsDetectionChallenge_v3p/env/bin/python3: No module named pip
    (env) s@s-Lenovo-ideapad-520-15IKB:~/Documents/github/CarPartsDetectionChallenge_v3p/env/bin$ pip install tensorflow
    Traceback (most recent call last):
      File "/home/s/Documents/github/CarPartsDetectionChallenge_v3p/env/bin/pip", line 5, in <module>
        from pip._internal.cli.main import main
    ModuleNotFoundError: No module named 'pip'
    (env) s@s-Lenovo-ideapad-520-15IKB:~/Documents/github/CarPartsDetectionChallenge_v3p/env/bin$ python3 --version
    Python 3.7.16

Already tried steps(didn't work) 1.

u@u-Lenovo-ideapad-520-15IKB:~/Documents/github/CarPartsDetectionChallenge_v3p$ sudo apt-get install python3-pip
[sudo] password for u: 
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
python3-pip is already the newest version (22.0.2+dfsg-1).
0 upgraded, 0 newly installed, 0 to remove and 165 not upgraded.
(env) u@u-Lenovo-ideapad-520-15IKB:~/Documents/github/CarPartsDetectionChallenge_v3p$ python3 -m pip install -r requirements.txt
/home/u/Documents/github/CarPartsDetectionChallenge_v3p/env/bin/python3: No module named pip
(env) u@u-Lenovo-ideapad-520-15IKB:~/Documents/github/CarPartsDetectionChallenge_v3p$ python3 -m pip3 install -r requirements.txt
/home/u/Documents/github/CarPartsDetectionChallenge_v3p/env/bin/python3: No module named pip3
(env) u@u-Lenovo-ideapad-520-15IKB:~/Documents/github/CarPartsDetectionChallenge_v3p$ pip3 install -r requirements.txt
Traceback (most recent call last):
  File "/home/u/Documents/github/CarPartsDetectionChallenge_v3p/env/bin/pip3", line 5, in <module>
    from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'
(env) u@u-Lenovo-ideapad-520-15IKB:~/Documents/github/CarPartsDetectionChallenge_v3p/env/bin$ sudo apt install python3-pip
python3-pip is already the newest version (22.0.2+dfsg-1).
0 upgraded, 0 newly installed, 0 to remove and 165 not upgraded.
(env) u@u-Lenovo-ideapad-520-15IKB:~/Documents/github/CarPartsDetectionChallenge_v3p/env/bin$ pip3 --version
Traceback (most recent call last):
  File "/home/u/Documents/github/CarPartsDetectionChallenge_v3p/env/bin/pip3", line 5, in <module>
    from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'
2

There are 2 answers

5
DiddlyDoo On

Try python3 -m pip3 install -r requirements.txt

If pip3 isn't found, it seems you need to install pip/pip3.

1
Mahimai Raja J On

Link your python with the pip package manager :

After activating the virtual Environment run the below commands.

For Windows :

python3 -m ensurepip

For Linux :

sudo apt-get install python3-pip