Skip to content

I can't use pip on WSL Ubuntu #4020

Closed
Closed
@hwooo

Description

@hwooo

Please fill out the below information:

  • Your Windows build number: 10.0.17763.475 / WSL Ubuntu 18.04.2

  • What you're doing and what's happening: Type sudo pip3 install [package]

  • What's wrong / what should be happening instead:
    Following error message comes out when trying to install packages via pip.

Collecting [package]
  Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', OSError(0, 'Error'))': /simple/[package]/
  Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', OSError(0, 'Error'))': /simple/[package]/
  Retrying (Retry(total=2, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', OSError(0, 'Error'))': /simple/[package]/
  Retrying (Retry(total=1, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', OSError(0, 'Error'))': /simple/[package]/
  Retrying (Retry(total=0, connect=None, read=None, redirect=None, status=None)) after connection broken by 'ProtocolError('Connection aborted.', OSError(0, 'Error'))': /simple/[package]/
  Could not find a version that satisfies the requirement flask-restful (from versions: )
No matching distribution found for [package]

None of these solutions work.

  • Re-install pip
  • Re-install WSL
  • sudo pip3 install [package]
  • pip3 install [package] with root account
  • sudo -H pip3 install [package]
  • pip install --user [package]

These commands works normally.

  • python -V (3.6)
  • pip3 --version (9.0.1)

Activity

Biswa96

Biswa96 commented on May 5, 2019

@Biswa96
hwooo

hwooo commented on May 6, 2019

@hwooo
Author

@Biswa96 How do I allow WSL Python in Windows Firewall? Is it possible to access WSL file from Windows?

Biswa96

Biswa96 commented on May 6, 2019

@Biswa96

Allow this path in Windows Firewall:

"C:\Users\username\AppData\Local\Packages\CanonicalGroupLimited.Ubuntu18.04onWindows_79rhkp1fndgsc\LocalState\rootfs\usr\bin\python3.6"

The path may vary in Ubuntu versions from Windows Store. Explanation here: https://superuser.com/a/1325042/726810

Also check the /etc/resolv.conf file if any DNS server is present. If not then try to add, for example, echo nameserver 1.1.1.1 > /etc/resolv.conf (yes, by overwriting).

matbrgz

matbrgz commented on May 6, 2019

@matbrgz

This could work

sudo apt -y purge python-pip
sudo python -m pip uninstall pip
sudo apt -y install python-pip
pip install --upgrade pip
echo "export PATH=\"${HOME}/.local/bin:$PATH\"" >>"${HOME}"/.bashrc

hwooo

hwooo commented on May 6, 2019

@hwooo
Author

@Biswa96 I can't configure the path.
firewall

hwooo

hwooo commented on May 6, 2019

@hwooo
Author

@MatheusRV pip install --upgrade pip gives me same error message 😢

Biswa96

Biswa96 commented on May 6, 2019

@Biswa96

Oh... Change the username to your user name in your PC

hwooo

hwooo commented on May 6, 2019

@hwooo
Author

That's my mistake...But result is same.

hwooo

hwooo commented on May 13, 2019

@hwooo
Author

The cause was my Kaspersky app. If I turn off it, everything works well. I've raised this issue to Kaspersky.

selvaprakash

selvaprakash commented on Aug 23, 2020

@selvaprakash

This worked for me.
sudo apt-get update
sudo apt-get upgrade
sudo apt install python3-pip

tuxdinosaur

tuxdinosaur commented on Sep 20, 2020

@tuxdinosaur

This worked for me.
sudo apt-get update
sudo apt-get upgrade
sudo apt install python3-pip

Thanks, this worked for me

42 remaining items

olvez

olvez commented on Feb 24, 2023

@olvez

No matter how many times I restart WSL, Windows automatically changes its name server and assign by itself.

So I change little bit as Belows,
in Windows Security > Firewall & Network Protection
In Public & private network turn off this 👇🏻
Block all incoming connections, including those in the list of allowed apps.

Restart WSL and its work like charm

Env :-
Win10
WSL2 / ubuntu 22.04

rraadd88

rraadd88 commented on Mar 11, 2023

@rraadd88

Within conda environment, I get this error when I use pip for the first time.
To fix it

  1. Install a python package using conda e.g. conda install matplotlib
  2. Then use pip install for other packages.

Env:
Win11 WSL2 / ubuntu 22.04
Firewall and proxy: off

Twetler

Twetler commented on Mar 31, 2023

@Twetler

Hello everybody,

To use pip3 on WSL2 you need to force using the ".exe" binary on your command line

pip            pip.exe     pip3         pip3.8         pip3.8.exe     pip3.exe
^ not work     ^ work      ^ not work   ^ not work     ^ work         ^ work

You need to install Python under windows before

me@computer:~$ whereis pip3.8
pip3: /usr/bin/pip3 /usr/local/bin/pip3 /usr/local/bin/pip3.8 /opt/az/bin/pip3 /opt/az/bin/pip3.6 /mnt/c/Python38/Scripts/pip3.exe /usr/share/man/man1/pip3.1.gz
me@computer:~$ whereis pip3.8.exe
pip3.8: /usr/local/bin/pip3.8 /mnt/c/Python38/Scripts/pip3.8.exe

This has solved my ERROR: Could not install packages due to an OSError when trying to pip install in WSL2

sageil

sageil commented on Jun 1, 2023

@sageil

I am using Python3.10 and this worked for me.

curl -sS https://bootstrap.pypa.io/get-pip.py | python3.10

Chances are you will have issues with pipenv installation, to resolve those, if they occur, use python3 -m pip install pipenv

dstkibrom

dstkibrom commented on Jun 27, 2023

@dstkibrom

I have been having this problem and did add all my proxy settings to /etc/environment and name resolutions to /etc/resolve.conf. But that was not enough for pip to work. But exporting the https_proxy in the terminal did the magic. I am not sure why this worked though.

export https_proxy="https://proxyIP:port"
subhojeet-chowdhury

subhojeet-chowdhury commented on Jul 8, 2023

@subhojeet-chowdhury

This worked for me. sudo apt-get update sudo apt-get upgrade sudo apt install python3-pip

Thankx a lot brother.

ikitcheng

ikitcheng commented on Jul 20, 2023

@ikitcheng

Hi, for me, the thing that fixed it was disconnecting my VPN connection and just connecting to wifi directly.

The-xploit

The-xploit commented on Sep 18, 2023

@The-xploit

I got error in upgrading pip and I can't install any pip packages. I remove it and re installed it but it saying error. Please tell me any Solutions

josephj1o4e1

josephj1o4e1 commented on Jan 19, 2024

@josephj1o4e1

This worked for me. sudo apt-get update sudo apt-get upgrade sudo apt install python3-pip

This didn't work. Had to:

  • open powershell on windows
  • run wsl --update

This saved me!

craigloewen-msft

craigloewen-msft commented on Nov 6, 2024

@craigloewen-msft
Member

Hey folks this issue is stale so we're closing it for our bookkeeping. It looks like there are already good answers here, if you're still seeing this please reopen a new issue for us to properly triage it! Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

      Participants

      @augustine-tran@TOTOleHero@piksel@iongion@pcuci

      Issue actions

        I can't use pip on WSL Ubuntu · Issue #4020 · microsoft/WSL