You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
pyenv-virtualenv is very slow on macOS Sequoia #490
Make sure no duplicated issue has already been reported in the pyenv-virtualenv issues. You should look in closed issues, too.
Make sure you are not asking us to help solving your specific issue.
GitHub issues is opened mainly for development purposes. If you want to ask someone to help solving your problem, go to some community site like Gitter, StackOverflow, etc.
Make sure your problem is not derived from packaging (e.g. Homebrew).
Please refer to the package documentation for the installation issues, etc.
Make sure your problem is not derived from other plugins.
This repository is maintaining the pyenv-virtualenv plugin only. Please refrain from reporting issues of other plugins here.
Description
Platform information (e.g. Ubuntu Linux 20.04): macOS 15.0 Sequoia
OS architecture (e.g. amd64): amd64 (MacbookPro 14,3)
pyenv version: v2.4.13
pyenv-virtualenv version: v1.2.4
Python version: 3.12.6
virtualenv version (if installed): none
I was using pyenv & pyenv-virtualenv on macOS 12.x Monterey for 2 years with great success.
Yesterday, I updated to macOS 15.0 Sequoia (clean install).
The shell was very slow with pyenv-virtualenv autoloading enabled.
It takes around 1.2 seconds when hitting a blank line in the shell.
I downgraded to macOS 13.x Ventura (clean install again) and the shell was instant again.
I don't expect you to fix macOS, but I wanted to report my experience with Sequoia to see if others users have the same problem. Apart from pyenv-virtualenv, pyenv + jenv + rbenv were also a bit slower. The rest of the apps were working well. I suspect Apple to have changed something with the terminal / shell...
I'll stick to Ventura for sometimes, and I'll give a try to Sonoma to see.
Reacted by native-api, Eike, Dan Brown, Jan Walzer, Kotaro Itoyama and Massimiliano Adamo
I encountered this same problem yesterday on my Intel Mac running macOS 14.7 (Sonoma) when I updated from Xcode 15.3 to Xcode 16. I presume that your fresh install of macOS 15 (Sequoia) had Xcode 16, and I'd be curious to see whether downgrading only Xcode without downgrading the OS would solve the problem. I'm also curious about whether this is a problem only on Intel Macs or if it's a problem on Apple Silicon as well.
I noticed a variety of pyenv and pyenv-virtualenv commands being much slower, and I was able to figure out that the command pyenv sh-activate --quiet command run in the shell hook was taking most of the time when I hit "Enter" on a blank line. I ran the following command to help test out the problem:
With Xcode 16, the command takes over 10 s to execute, while with Xcode 15.3, the command takes ~0.3 s to execute.
I can help with debugging the problem because I can't delay upgrading Xcode indefinitely. However, I have no clue how to profile shell scripts. If anyone has tooling recommendations, I can hopefully figure out exactly where the regression is happening.
I forgot to mention this, but I switched to an Apple silicon laptop a week or two after encountering this issue, and I had no problems using Xcode 16 on it. I think this regression is purely for Intel Mac users.
Someone else is obviously free to debug this, but I'm not going to spend the time debugging it myself.
I'm not sure if this is related to the new macOS version or not, but I have long noticed that pyenv-virtualenvs is incredibly slow, especially if you have many virtual environments (I currently have 128). Since that is called during pyenv-sh-activate, I imagine that may be part of the problem.
I've been digging into this and found the call from pyenv-virtualenvs --> pyenv-virtualenv-prefix --> pyenv-prefix to be the source of the slowness.
Fixed in v1.3.0 via #523. The per-prompt activate calls that caused the slowness have been replaced with a stat-based cache. The slowness was the same underlying fork overhead documented in #259.
@samdoran's pointer to #502 for the pyenv virtualenvs listing cost remains relevant.
Activity
kozlek commentedon Sep 21, 2024
I did a macOS 14.7 Sonoma clean install on an external SSD and
pyenv-virtualenvis behaving normally, without any delays.At least on my platform, macOS Sequoia has a huge issue with some shell programs.
I recommend to postpone the Sequoia upgrade until this is fixed on macOS side.
aphedges commentedon Sep 26, 2024
I encountered this same problem yesterday on my Intel Mac running macOS 14.7 (Sonoma) when I updated from Xcode 15.3 to Xcode 16. I presume that your fresh install of macOS 15 (Sequoia) had Xcode 16, and I'd be curious to see whether downgrading only Xcode without downgrading the OS would solve the problem. I'm also curious about whether this is a problem only on Intel Macs or if it's a problem on Apple Silicon as well.
I noticed a variety of
pyenvandpyenv-virtualenvcommands being much slower, and I was able to figure out that thecommand pyenv sh-activate --quietcommand run in the shell hook was taking most of the time when I hit "Enter" on a blank line. I ran the following command to help test out the problem:With Xcode 16, the command takes over 10 s to execute, while with Xcode 15.3, the command takes ~0.3 s to execute.
I can help with debugging the problem because I can't delay upgrading Xcode indefinitely. However, I have no clue how to profile shell scripts. If anyone has tooling recommendations, I can hopefully figure out exactly where the regression is happening.
native-api commentedon Sep 26, 2024
#259 (comment):
Also add the same
dateinvocation to PS4 assignments throughout Pyenv and Pyenv-Virtualenv and setPYENV_DEBUG=1aphedges commentedon Oct 23, 2024
I forgot to mention this, but I switched to an Apple silicon laptop a week or two after encountering this issue, and I had no problems using Xcode 16 on it. I think this regression is purely for Intel Mac users.
Someone else is obviously free to debug this, but I'm not going to spend the time debugging it myself.
andrewaylett commentedon Dec 27, 2024
Here's the timed output from my machine:
Then the call to pyenv-sh-activate:
It's a 2019 13-inch MacBook Pro, 2.8GHz i7, Sequoia 15.1.1.
If I'm not outputting debug information it's faster, but not particularly fast:
samdoran commentedon Feb 13, 2025
I'm not sure if this is related to the new macOS version or not, but I have long noticed that
pyenv-virtualenvsis incredibly slow, especially if you have many virtual environments (I currently have 128). Since that is called duringpyenv-sh-activate, I imagine that may be part of the problem.I've been digging into this and found the call from
pyenv-virtualenvs-->pyenv-virtualenv-prefix-->pyenv-prefixto be the source of the slowness.I'll put up a PR soon with a fix.
samdoran commentedon Feb 13, 2025
@kozlek Try out the changes in #502 and see if that helps things any.
native-api commentedon Mar 4, 2026
pyenv/pyenv#3411 has an example of a profiling technique to find hot spots in Bash code
native-api commentedon Mar 25, 2026
#523
jakelodwick commentedon Mar 26, 2026
Fixed in v1.3.0 via #523. The per-prompt
activatecalls that caused the slowness have been replaced with a stat-based cache. The slowness was the same underlying fork overhead documented in #259.@samdoran's pointer to #502 for the
pyenv virtualenvslisting cost remains relevant.