Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Every single command from pip runs super slow #8485

Closed
peidaqi opened this issue Jun 23, 2020 · 56 comments
Closed

Every single command from pip runs super slow #8485

peidaqi opened this issue Jun 23, 2020 · 56 comments
Labels
C: keyring Related to pip's keyring integration type: bug A confirmed bug or unintended behavior

Comments

@peidaqi
Copy link

peidaqi commented Jun 23, 2020

Environment

  • pip version: pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)
  • Python version: 3.8.2
  • OS: Ubuntu 20.04 (Windows WSL2 - kernel 4.19.104-microsoft-standard) on Windows 10 (19041)

Description

Any commands on pip3 runs super slow including simple ones like:
pip3 list

It used to take 1~2 seconds and now it's like a minute.

Expected behavior

How to Reproduce

Tried to clean cache dir and it didn't work.
Tried to purge python3-pip package and reinstall and didn't work.

Not sure if it's linked to the recent Windows 10 19041 update.

@triage-new-issues triage-new-issues bot added the S: needs triage Issues/PRs that need to be triaged label Jun 23, 2020
@uranusjr
Copy link
Member

What are you referring by “it used to”? Does this slowdown happen because of a pip upgrade or a system upgrade? If it happens out of nowhere, it is very likely not a pip problem, but something happening on your particular machine, which pip does not have control over.

@peidaqi
Copy link
Author

peidaqi commented Jun 23, 2020

No, I didn't do any pip upgrade. Windows 10 does make frequent updates but I cannot fathom how this impacts performance with pip inside WSL2.

I'm hoping someone could point me a direction on how I can even trace this problem. Right now pip doesn't output any error messages so no way to know what's going on.

@pradyunsg
Copy link
Member

Could you share how many packages are already installed (i.e. the output of pip list)? It might be related to pip's internal logic [1] that tried to look at all the installed packages before any output processing.

[1] pkg_resources's WorkingSet construction on load, for those wondering what I'm talking about

@piyushchauhan2011
Copy link

piyushchauhan2011 commented Jul 12, 2020

Same issue with me too. I ran pip3 list command and it took around 10+ seconds to list out packages. For now I create virtual environment using pipenv which removes the problem. I think it might be interfering with the sharing of executables between wsl2 linux and windows. I'm not sure what is the source of problem though!

@uranusjr
Copy link
Member

I think it might be interfering with the sharing of executables between wsl2 linux and windows

This sounds plausible. WSL2’s filesystem performance is terrible if you access the Windows filesystem at the Linux side. What is the Python associated to your pip3 command? Can you provide its sys.path? Does this happen if you run pip3 at a different location? Does it matter if the location is in the Linux filesystem or the Windows side?

@piyushchauhan2011
Copy link

If we run same pip3 list on windows powershell, it's instant and the issue doesn't happen.

Sys path without pipenv environment activated

['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/<user>/.local/lib/python3.8/site-packages', '/usr/local/lib/python3.8/dist-packages', '/usr/lib/python3/dist-packages']

Sys path with pipenv environment activated

['', '/usr/lib/python38.zip', '/usr/lib/python3.8', '/usr/lib/python3.8/lib-dynload', '/home/<user>/.local/share/virtualenvs/myproj-SiazyaGz/lib/python3.8/site-packages']

It could be possible if sys path is changed for global, then pip3 won't interfere with windows one. I haven't tried it out!

@uranusjr
Copy link
Member

Hmm, none of the directories seem out of ordinary. Do you happen to mount any of the Windows directories? For example, do you symlink your home directory (or anything listed in sys.path) to a Windows directory? Or do you run the command in a directory under /mnt?

I would probably try to temporarily move some of the entries listed in sys.path away (espacially the ~/.local/lib one) and see if that changes anything. Or maybe you can just insert a few profilers into the Python runtime and see what exactly are slowing things down. There are many tricks you can do to isolate the problem. That would be immensely more useful than me (or anyone without physical access to your machine) trying to troubleshoot against thin air.

@ngraymon
Copy link

ngraymon commented Jul 24, 2020

Edit: This may somehow be linked to the display? The slowdown largely goes away (takes 0.5 seconds) when I start up an X11 server (using MobaXterm). The reason I found this issue was that matplotlib was super slow so I tried to use pip to reinstall. I forgot that I needed to run an Xterm to use matplotlib.

I have also encountered this problem and have the same output from my python's sys.path as piyushchauhan2011. I have a symlink in my home directory to a Windows directory like so
test -> /mnt/c/Users/<user>/Documents/<git_project_folder>/

I'm developing a python package whose results need to be bench marked against a program that can only run in a unix environment. I use sublime test to edit the files in my windows directory and use the WSL2 to run the benchmark code on those files through the symlink.

I can run the following commands without any slowdown: check, show, config
I'm using pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

Running pip3 list does return a result but it takes ~ 30 seconds.
I have about 100 packages installed.

I tried the following without any success
python3 -m pip --retries 2 --timeout 5 --no-cache-dir --isolated --verbose list
I have tried running pip both inside the WSL2 filesystem and at the Windows side each of them suffering the same slowdown.

I'm not 100% what the best way of changing the sys.path would be but here is my attempt:
I launched ipython3 which starts with a sys.path of:

'/usr/bin',
 '/usr/lib/python38.zip',
 '/usr/lib/python3.8',
 '/usr/lib/python3.8/lib-dynload',
 '',
 '/home/<user>/.local/lib/python3.8/site-packages',
 '/usr/local/lib/python3.8/dist-packages',
 '/usr/lib/python3/dist-packages',
 '/usr/lib/python3/dist-packages/IPython/extensions',
 '/home/<user>/.ipython']

Which I backup as follows backup = sys.path.copy()
At this point I confirmed that if I use run '/usr/bin/pip3' list I still encounter the slowdown.
However, when after that I set sys.path = [] and run again I get a ModuleNotFoundError: No module named 'pyparsing'. This result repeats each time I run again. BUT! Once I set sys.path = backup now run '/usr/bin/pip3' list miraculously works!
The output of using time:

CPU times: user 12.2 ms, sys: 426 µs, total: 12.6 ms
Wall time: 11.8 ms

So clearly there is something wrong with the paths.
Afterwards I can again set sys.path =[] and run '/usr/bin/pip3' list still works for some reason.

I'm not sure if this is relevant but I figured I'd mention it:
After using the run command my sys.path gets populated as follows (after having been set to an empty list)

['/usr/share/python-wheels/idna-2.8-py2.py3-none-any.whl',
 '/usr/share/python-wheels/distlib-0.3.0-py2.py3-none-any.whl',
 '/usr/share/python-wheels/msgpack-0.6.2-py2.py3-none-any.whl',
 '/usr/share/python-wheels/lockfile-0.12.2-py2.py3-none-any.whl',
 '/usr/share/python-wheels/pytoml-0.1.21-py2.py3-none-any.whl',
 '/usr/share/python-wheels/retrying-1.3.3-py2.py3-none-any.whl',
 '/usr/share/python-wheels/requests-2.22.0-py2.py3-none-any.whl',
 '/usr/share/python-wheels/setuptools-44.0.0-py2.py3-none-any.whl',
 '/usr/share/python-wheels/pep517-0.8.2-py2.py3-none-any.whl',
 '/usr/share/python-wheels/chardet-3.0.4-py2.py3-none-any.whl',
 '/usr/share/python-wheels/webencodings-0.5.1-py2.py3-none-any.whl',
 '/usr/share/python-wheels/CacheControl-0.12.6-py2.py3-none-any.whl',
 '/usr/share/python-wheels/ipaddr-2.2.0-py2.py3-none-any.whl',
 '/usr/share/python-wheels/certifi-2019.11.28-py2.py3-none-any.whl',
 '/usr/share/python-wheels/urllib3-1.25.8-py2.py3-none-any.whl',
 '/usr/share/python-wheels/wheel-0.34.2-py2.py3-none-any.whl',
 '/usr/share/python-wheels/appdirs-1.4.3-py2.py3-none-any.whl',
 '/usr/share/python-wheels/packaging-20.3-py2.py3-none-any.whl',
 '/usr/share/python-wheels/html5lib-1.0.1-py2.py3-none-any.whl',
 '/usr/share/python-wheels/six-1.14.0-py2.py3-none-any.whl',
 '/usr/share/python-wheels/pip-20.0.2-py2.py3-none-any.whl',
 '/usr/share/python-wheels/colorama-0.4.3-py2.py3-none-any.whl',
 '/usr/share/python-wheels/progress-1.5-py2.py3-none-any.whl',
 '/usr/share/python-wheels/pkg_resources-0.0.0-py2.py3-none-any.whl',
 '/usr/share/python-wheels/pyparsing-2.4.6-py2.py3-none-any.whl',
 '/usr/share/python-wheels/contextlib2-0.6.0-py2.py3-none-any.whl',
 '/usr/share/python-wheels/distro-1.4.0-py2.py3-none-any.whl',
 '/usr/bin',
 '/usr/lib/python38.zip',
 '/usr/lib/python3.8',
 '/usr/lib/python3.8/lib-dynload',
 '',
 '/home/<user>/.local/lib/python3.8/site-packages',
 '/usr/local/lib/python3.8/dist-packages',
 '/usr/lib/python3/dist-packages',
 '/usr/lib/python3/dist-packages/IPython/extensions',
 '/home/<user>/.ipython']

Which still suffers the slowdown until the sys.path is set to an empty list and then reset back to the original list or this list.

@uranusjr
Copy link
Member

This may somehow be linked to the display? The slowdown largely goes away (takes 0.5 seconds) when I start up an X11 server (using MobaXterm). The reason I found this issue was that matplotlib was super slow so I tried to use pip to reinstall. I forgot that I needed to run an Xterm to use matplotlib.

Maybe…? The entirely issue is very weird to me. If this is a sys.path issue, wouldn’t the same slowdown happen for all Python imports, not just pip? I am quite stumped 😞

@MattiaFailla
Copy link

MattiaFailla commented Aug 2, 2020

Hello, my environment is:

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.4 LTS"
NAME="Ubuntu"
VERSION="18.04.4 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.4 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

With Python 3.6.9 and pip 9.0.1 and I can confirm that pip is extremely slow with every command (especially with install)

My pip3 list is

asn1crypto (0.24.0)
attrs (17.4.0)
Automat (0.6.0)
chardet (3.0.4)
configobj (5.0.6)
constantly (15.1.0)
cryptography (2.1.4)
distro-info (0.18ubuntu0.18.04.1)
hyperlink (17.3.1)
idna (2.6)
incremental (16.10.1)
keyring (10.6.0)
keyrings.alt (3.0)
netifaces (0.10.4)
pip (9.0.1)
pyasn1 (0.4.2)
pyasn1-modules (0.2.1)
pycrypto (2.6.1)
pygobject (3.26.1)
pyOpenSSL (17.5.0)
python-apt (1.6.5+ubuntu0.3)
python-debian (0.1.32)
pyxdg (0.25)
PyYAML (3.12)
SecretStorage (2.3.1)
service-identity (16.0.0)
setuptools (39.0.1)
six (1.11.0)
Twisted (17.9.0)
ufw (0.36)
unattended-upgrades (0.1)
wheel (0.30.0)

@ngraymon
Copy link

ngraymon commented Aug 3, 2020

@MattiaFailla If you want a temporary fix I recommend running an X11 server such as MobaXterm(or some other equivalent). I don't understand why, but it did fix my slowdown issue for all commands.

@MattiaFailla
Copy link

@ngraymon that’s odd but I will try this temp-fix.
Thanks!
I'll update this issue once tried.

@ngraymon
Copy link

ngraymon commented Aug 3, 2020

Just to confirm that the behavior is still the same I checked just now:

Running time pip3 list inside a Windows Terminal on WSL2:
image
After starting MobaXterm and running time pip3 list in the same terminal:
image

@MattiaFailla
Copy link

@ngraymon Hello,
I have resolved the issue, please try the following steps:

  • Do not run pip commands with sudo
  • apt-update && apt-upgrade
  • Reboot the server/computer
  • Keep close attention to docker, last night I noticed that the python3 process was being intensely used by the swarm

@ngraymon
Copy link

ngraymon commented Aug 4, 2020

@MattiaFailla
I'm glad you resolved your issue.
I tried your suggestions but it did not solve the issue.
I don't run pip with sudo, but I did install pip3 using sudo apt install python3-pip, maybe that is relevant?
I'm happy with the way things are for myself as I need an X server anyways since I'm plotting using matplotlib.

@pradyunsg
Copy link
Member

@ngraymon could you run python -m pip, and see if that is also slow?

If it is, and you have a new-enough Python version, please provide us the output of python -X importtime -m pip -v. If the slowdown is in the imports, this will help us know.

@pradyunsg pradyunsg added S: awaiting response Waiting for a response/more information state: needs reproducer Need to reproduce issue type: bug A confirmed bug or unintended behavior labels Aug 5, 2020
@triage-new-issues triage-new-issues bot removed the S: needs triage Issues/PRs that need to be triaged label Aug 5, 2020
@ngraymon
Copy link

ngraymon commented Aug 5, 2020

@pradyunsg
Hello,

I ran time python3 -m pip without any command for pip which replies with the help message in this time
image
However if I run time python3 -m pip list
image
Running time python3 -m pip check which has not/ still isn't affected by the slow down
image

I ran the following:

  • python3 -X importtime -m pip -v and attached that asout_1.txt

  • python3 -X importtime -m pip -v list and attached that as out_list.txt

  • python3 -X importtime -m pip -v check and attached that as out_check.txt

It appears the culprit for the list command is keyring.core?
import time: 96023197 | 96029594 | keyring.core

Hopefully that is helpful :)

@pfmoore
Copy link
Member

pfmoore commented Aug 5, 2020

It appears the culprit for the list command is keyring.core?

Combined with the weird thing around having an X server helping, I wonder if keyring depends on a GUI, and there's some code in there that tries to find X and causes a delay until it concludes there isn't one?

@ngraymon
Copy link

ngraymon commented Aug 5, 2020

@pfmoore
Based on their page at pypi it seems it requires either D-Bus or an X11 server?

I tried python3 -m keyring --disable and export PYTHON_KEYRING_BACKEND=keyring.backends.null.Keyring but neither seemed to fix the issue.

image

@chrahunt
Copy link
Member

chrahunt commented Aug 6, 2020

jaraco/keyring#434 seems related, but the advice there on disabling points to the docs which states what you've already tried.

@cjpellicci
Copy link

cjpellicci commented Aug 6, 2020

Experiencing this issue as well, believe it started after running a routine sudo apt-get update && sudo apt-get upgrade yesterday. It is definitely related to keyring and the display somehow. In addition to the fix of having an X-Server running, I was able to fix the issue by removing the line I had in my .bashrc file pointing the Display to WSL2's IP Address. The line in question is:
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0

After removing this line from .bashrc and restarting WSL2, pip behaves as expected. Not quite sure if this points anyone in the right direction, as I'm not sure how to proceed from here.

@cjpellicci
Copy link

cjpellicci commented Aug 6, 2020

It appears as if I was able to permanently fix the issue by updating keyring with pip3 install -U keyring and ensuring that
[backend]
default-keyring=keyring.backends.null.Keyring
is set in the keyring config file at ~/.config/python_keyring/keyringrc.cfg

@ngraymon
Copy link

ngraymon commented Aug 6, 2020

Wonderful, cjpellicci's suggestion of pip3 install -U keyring did the trick.
I also had to move ~/.local/share/python_keyring/keyringrc.cfg to ~/.config/share/python_keyring/keyringrc.cfg.
Running pip3 list takes 1/2 a second now instead of 90 seconds.
This is without any X server running.

@peidaqi
Copy link
Author

peidaqi commented Aug 10, 2020

The above doesn't seem to work for me. There's no keyringrc.cfg in either ~/.local/share/python_keyring/ or ~/.config/share/python_keyring/.

Could this be a different behaviour between WSL Ubuntu and Ubuntu?

@pradyunsg
Copy link
Member

Has it been raised as a bug there? I

Yes: jaraco/keyring#403

@AnimeshRy
Copy link

Experiencing this issue as well, believe it started after running a routine sudo apt-get update && sudo apt-get upgrade yesterday. It is definitely related to keyring and the display somehow. In addition to the fix of having an X-Server running, I was able to fix the issue by removing the line I had in my .bashrc file pointing the Display to WSL2's IP Address. The line in question is:
export DISPLAY=$(cat /etc/resolv.conf | grep nameserver | awk '{print $2; exit;}'):0.0

After removing this line from .bashrc and restarting WSL2, pip behaves as expected. Not quite sure if this points anyone in the right direction, as I'm not sure how to proceed from here.

Worked for me! Thanks

@takluyver
Copy link
Member

takluyver commented Dec 11, 2020

This should be much better with keyring 21.5 or above. It's possible that the delay will occur when code tries to use keyring instead of at import, but it sounds like a lot of people are hitting this in cases where keyring is imported but never used, and those cases should be fixed. If you still see a ~25 second delay with an up to date keyring, please check a standalone import keyring, and report it on keyring (after checking if there's already an issue, naturally!).

Technical details

Keyring tries at import to determine which of its backends to use. There are two main Linux backends: SecretStorage (nominally a standard, but mainly implemented by Gnome) and KWallet (KDE). Both are accessed through D-Bus, a local communication system. D-Bus supports 'service activation', i.e. starting a program when there is a request for it, and then passing it the request. These long waits occur when one of these services is installed but doesn't start correctly for some reason - D-Bus' default configuration allows a very long time for a service to start before it gives up and sends back an error. Keyring was making a request to each service as part of choosing which to use, so this wait could occur on import. Thanks to @siebenmann for helping to pin this down.

The fix, for now, is to avoid making requests to the services during backend selection. Instead, keyring will just check if each service is available. This should never lead to a long wait. However, you may get a long wait instead if the code tries to get or set a password with keyring, because at that point it will make a request to the service, which may need to be activated.

Keyring is still doing somewhat complex operations on import, which is not ideal. I'd hope that a future version can defer choosing a backend until a keyring function is called, so it has no surprising behaviour on import.

@takluyver
Copy link
Member

And with keyring 21.6, keyring should initialise its backend lazily, so importing it should take no longer than any other similarly sized package.

@nbraud
Copy link

nbraud commented Jan 6, 2021

it sounds like a lot of people are hitting this in cases where keyring is imported but never used, and those cases should be fixed

FYI, I included a patch in #9434 that makes the loading of keyring lazy.

@heidemn-faro
Copy link

Adding another possible data point:
pip list took around 90 seconds under WSL2.
I was setting the DISPLAY environment variable to an X server running under the windows desktop. Clearing the DISPLAY environment variable or launching my X server changed the time to 0.343s.

@poday This also works for me, thanks a lot!

I've now added to my bashrc:
alias pip3='DISPLAY= pip3'

@yishaiSilver
Copy link

Hey guys, this might be pretty dumb, but I was struggling with this for a while and "sudo apt-get update", "sudo apt-get upgrade" fixed it for me.

@skrobchik
Copy link

skrobchik commented May 9, 2021

Edit: This may somehow be linked to the display? The slowdown largely goes away (takes 0.5 seconds) when I start up an X11 server (using MobaXterm). The reason I found this issue was that matplotlib was super slow so I tried to use pip to reinstall. I forgot that I needed to run an Xterm to use matplotlib.

I was having the same problems, but I'm using X410. Before turning it on pip3 list was taking a very long time (couldn't wait for it to finish). When I turned on X410, it finished almost immediately when running it again.

@AyanUpadhaya
Copy link

I even see request lib is also performing slow. I switched to linux because I was frustrated with windows updates but now I think windows 10 is much faster in executing web scraping. I think I will go back to windows 10.

@alexspringgit
Copy link

I've now added to my bashrc:
alias pip3='DISPLAY= pip3'

@heidemn-faro
Super-easy, thanks a lot!
The following worked for both pip and pip3:

$ alias pip3='DISPLAY= pip3'
$ alias pip='DISPLAY= pip'
$ pip3 list #speeded-up
$ pip list #speeded-up
$ echo ${DISPLAY} #not changed

Environment:

  • pip 20.0.2
  • Python 3.8.5
  • Ubuntu 20.04
  • WSL2

@AyanUpadhaya
Copy link

Any Way
I used a mirror to download packages fast as I didn't find any other way. Even it takes 10 secs but better than waiting for 3minutes.

pip install --upgrade pip --index-url https://mirrors.sustech.edu.cn/pypi/simple
pip config set global.index-url https://mirrors.sustech.edu.cn/pypi/simple

@s-weigand
Copy link

@AyanUpadhaya That sounds like the issue I had (windows and linux) and was a problem with IPv6.
For me the solution was to change the network settings to prefer IPv4 over IPv6

@SomwareHR
Copy link

~/.config/python_keyring/keyringrc.cfg

This file didn't exist on my machine, I just created it and it works.

@Jacobcaller
Copy link

@AyanUpadhaya That sounds like the issue I had (windows and linux) and was a problem with IPv6. For me the solution was to change the network settings to prefer IPv4 over IPv6

Pip install was very slow, and this solved it
Ubuntu 20.04 Kernel 5.15.1

@ZelphirKaltstahl
Copy link

@AyanUpadhaya That sounds like the issue I had (windows and linux) and was a problem with IPv6. For me the solution was to change the network settings to prefer IPv4 over IPv6

Pip install was very slow, and this solved it Ubuntu 20.04 Kernel 5.15.1

This seems to be the solution for me as well.

To have the solution directly here in the issue, here is what I have in my /etc/gai.conf:

...
#    For sites which prefer IPv4 connections change the last line to
#

#############
# USER EDIT #
#############
precedence ::ffff:0:0/96  100
############
# EDIT END #
############
...

@q0w q0w mentioned this issue Mar 10, 2022
1 task
@Matt-Seath
Copy link

Not sure if this was covered previously, but in my case pip started causing problems after I had scrapped my existing virtualenv for a repo and initiated a new one. At this stage it would take a whole minute before any pip command would even begin executing while i was working in my new virtualenv.

Solution:
Because i had deleted my env/ directory, my python interpreter had reset to use the global python. By switching the interpreter back to one in my virtualenv the issue had been resolved.

@wyl513510
Copy link

I guess you can try to active xming or some like that.

@epheien
Copy link

epheien commented Jul 17, 2023

same issue: pip3 list 0.66s user 0.05s system 2% cpu 25.744 total

my env

Ubuntu 20.04.5 LTS
Python 3.8.10
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8)

and output of strace pip3 list

close(3)                                = 0
openat(AT_FDCWD, "/System/Library/Frameworks/Security.framework/Versions/A/Security", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC, 0) = 3
connect(3, {sa_family=AF_UNIX, sun_path="/run/user/1000/bus"}, 20) = 0
fcntl(3, F_GETFL)                       = 0x2 (flags O_RDWR)
fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK)    = 0
geteuid()                               = 1000
getsockname(3, {sa_family=AF_UNIX}, [128->2]) = 0
poll([{fd=3, events=POLLOUT}], 1, 0)    = 1 ([{fd=3, revents=POLLOUT}])
sendto(3, "\0", 1, MSG_NOSIGNAL, NULL, 0) = 1
sendto(3, "AUTH EXTERNAL 31303030\r\n", 24, MSG_NOSIGNAL, NULL, 0) = 24
poll([{fd=3, events=POLLIN}], 1, -1)    = 1 ([{fd=3, revents=POLLIN}])
read(3, "OK a9161807d76d67fea389c6f364b56"..., 2048) = 37
poll([{fd=3, events=POLLOUT}], 1, -1)   = 1 ([{fd=3, revents=POLLOUT}])
sendto(3, "NEGOTIATE_UNIX_FD\r\n", 19, MSG_NOSIGNAL, NULL, 0) = 19
poll([{fd=3, events=POLLIN}], 1, -1)    = 1 ([{fd=3, revents=POLLIN}])
read(3, "AGREE_UNIX_FD\r\n", 2048)      = 15
poll([{fd=3, events=POLLOUT}], 1, -1)   = 1 ([{fd=3, revents=POLLOUT}])
sendto(3, "BEGIN\r\n", 7, MSG_NOSIGNAL, NULL, 0) = 7
poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
sendmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="l\1\0\1\0\0\0\0\1\0\0\0n\0\0\0\1\1o\0\25\0\0\0/org/fre"..., iov_len=128}, {iov_base="", iov_len=0}], msg_iovlen=2, msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 128
poll([{fd=3, events=POLLIN}], 1, 25000) = 1 ([{fd=3, revents=POLLIN}])
recvmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="l\2\1\1\n\0\0\0\1\0\0\0=\0\0\0\6\1s\0\5\0\0\0:1.16\0\0\0"..., iov_len=2048}], msg_iovlen=1, msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 260
recvmsg(3, {msg_namelen=0}, MSG_CMSG_CLOEXEC) = -1 EAGAIN (Resource temporarily unavailable)
futex(0x7f5bdc188f38, FUTEX_WAKE_PRIVATE, 2147483647) = 0
eventfd2(0, EFD_CLOEXEC|EFD_NONBLOCK)   = 4
write(4, "\1\0\0\0\0\0\0\0", 8)         = 8
futex(0x7f5bdc188f38, FUTEX_WAKE_PRIVATE, 2147483647) = 0
fstat(3, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
fcntl(3, F_GETFL)                       = 0x802 (flags O_RDWR|O_NONBLOCK)
write(4, "\1\0\0\0\0\0\0\0", 8)         = 8
sendmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="l\1\0\1\34\0\0\0\2\0\0\0\177\0\0\0\1\1o\0\25\0\0\0/org/fre"..., iov_len=144}, {iov_base="\27\0\0\0org.freedesktop.secrets\0", iov_len=28}], msg_iovlen=2, msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 172
poll([{fd=3, events=POLLIN}], 1, 25000) = 1 ([{fd=3, revents=POLLIN}])
recvmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="l\3\1\1H\0\0\0\3\0\0\0u\0\0\0\6\1s\0\5\0\0\0:1.16\0\0\0"..., iov_len=2048}], msg_iovlen=1, msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 208
write(4, "\1\0\0\0\0\0\0\0", 8)         = 8
recvmsg(3, {msg_namelen=0}, MSG_CMSG_CLOEXEC) = -1 EAGAIN (Resource temporarily unavailable)
sendmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="l\1\0\1 \0\0\0\3\0\0\0\210\0\0\0\1\1o\0\25\0\0\0/org/fre"..., iov_len=152}, {iov_base="\27\0\0\0org.freedesktop.secrets\0\0\0\0\0", iov_len=32}], msg_iovlen=2, msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 184
poll([{fd=3, events=POLLIN}], 1, 25000


) = 0 (Timeout)
sendmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="l\1\0\1\25\0\0\0\4\0\0\0\177\0\0\0\1\1o\0\25\0\0\0/org/fre"..., iov_len=144}, {iov_base="\20\0\0\0org.kde.kwalletd\0", iov_len=21}], msg_iovlen=2, msg_controllen=0, msg_flags=0}, MSG_NOSIGNAL) = 165

poll([{fd=3, events=POLLIN}], 1, 25000) = 0 (Timeout) hang

@epheien
Copy link

epheien commented Jul 17, 2023

I update keyring solve my problem
pip3 install keyring==19.3.0

@pradyunsg
Copy link
Member

This should not be an issue with the latest pip and the latest keyring. If you're still seeing this with the latest versions of pip and keyring, please file a new issue. :)

@danielmacuare
Copy link

danielmacuare commented Aug 21, 2023

@AyanUpadhaya That sounds like the issue I had (windows and linux) and was a problem with IPv6. For me the solution was to change the network settings to prefer IPv4 over IPv6

Similar to this, I solved my issue by disabling IPv6 only on one interface. If you don't even use IPv6 you can easily deactivate it globally or only on your interface.

TDLR: IPv6 resolution is preferred over IPv4 making installing a package painfully slow
Easy workaround to test: Disable IPv6, test and confirm if this solve your issues

# Check if IPv6 is enabled in your system (0 Means Enable, 1 Means disable)
sysctl -a 2>/dev/null | grep disable_ipv6 

# Disable IPv6
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1 
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=1

# Test
poetry install

# Re-enable IPv6
sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=0
sudo sysctl -w net.ipv6.conf.lo.disable_ipv6=0

This solved my issues with Poetry and PIP being extremely slow to install packages.

I've written a more extensive post on this workaround. Have a look if you want to get more information.
Blog Post: IPv6 Issues with Python Package Managers

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
C: keyring Related to pip's keyring integration type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests