Comments (7)
The performance tuning of shell script is hell 😞
If the speed is important for your installation, users of pyenv-virtualenv have an option to skip setting up eval "$(pyenv virtualenv-init -)"
in his/her shell configuration. Since it's just for doing activate/deactivate of virtualenv based on current pyenv versions, user of pyenv-virtualenv still can switch virtualenvs as same manor as vanilla pyenv does. It would not cause problem any serious problems on most cases. I believe it'd be sufficient as a solution for this.
from pyenv-virtualenv.
@wakenmeng
I see - it's not running the "init", but it's the code setup to autoactivate your virtualenv.
I am not using this myself (because of the performance implications).
I recommend using something like https://github.com/Tarrasch/zsh-autoenv, which allows you to trigger scripts when entering/leaving some directory. From there you can then call pyenv activate
or pyenv deactivate
(on the "leave" event).
from pyenv-virtualenv.
The eval "$(pyenv virtualenv-init -)"
is optional. If the performance is an issue for you, you can omit the configuration. The automatic activation feature will not be available though. See also https://github.com/yyuu/pyenv-virtualenv#activate-virtualenv
from pyenv-virtualenv.
I got this problem, too! Is it necessary to run eval "$(pyenv virtualenv-init -)"
everytime I press enter? Is there better way to init once when open a new zsh?
from pyenv-virtualenv.
Is it necessary to run eval "$(pyenv virtualenv-init -)" everytime I press enter?
That should not be the case..
Please try using export PYENV_DEBUG=1
to see what is going on.
@marshallpierce
Can you check if running pyenv activate --no-error --verbose
manually is slow as well?
Apart from that, using export PYENV_DEBUG=1
might help you debugging this, too.
from pyenv-virtualenv.
@marshallpierce @wakenmeng
Can you provide feedback, please?
from pyenv-virtualenv.
@blueyed, appologize for this long time. I omit the configuration eval "$(pyenv virtualenv-init -)"
and it works for me. And if I add this configuration, everytime I press enter or ls
, cd
, this what it print when I set PYENV_DEBUG=1
:
++ [pyenv:15] type -p greadlink readlink
++ [pyenv:15] head -1
+ [pyenv:15] READLINK=/usr/bin/readlink
+ [pyenv:16] '[' -z /usr/bin/readlink ']'
+ [pyenv:21] unset GREP_OPTIONS
+ [pyenv:41] '[' -z /usr/local/opt/pyenv ']'
+ [pyenv:44] PYENV_ROOT=/usr/local/opt/pyenv
+ [pyenv:46] export PYENV_ROOT
+ [pyenv:48] '[' -z '' ']'
++ [pyenv:49] pwd
+ [pyenv:49] PYENV_DIR=/Users/meng
+ [pyenv:58] export PYENV_DIR
+ [pyenv:61] shopt -s nullglob
++ [pyenv:63] abs_dirname /usr/local/bin/pyenv
+++ [pyenv:28] pwd
++ [pyenv:28] local cwd=/Users/meng
++ [pyenv:29] local path=/usr/local/bin/pyenv
++ [pyenv:31] '[' -n /usr/local/bin/pyenv ']'
++ [pyenv:32] cd /usr/local/bin
++ [pyenv:33] local name=pyenv
+++ [pyenv:34] resolve_link pyenv
+++ [pyenv:24] /usr/bin/readlink pyenv
++ [pyenv:34] path=../Cellar/pyenv/20141012/bin/pyenv
++ [pyenv:31] '[' -n ../Cellar/pyenv/20141012/bin/pyenv ']'
++ [pyenv:32] cd ../Cellar/pyenv/20141012/bin
++ [pyenv:33] local name=pyenv
+++ [pyenv:34] resolve_link pyenv
+++ [pyenv:24] /usr/bin/readlink pyenv
++ [pyenv:34] path=../libexec/pyenv
++ [pyenv:31] '[' -n ../libexec/pyenv ']'
++ [pyenv:32] cd ../libexec
++ [pyenv:33] local name=pyenv
+++ [pyenv:34] resolve_link pyenv
+++ [pyenv:24] /usr/bin/readlink pyenv
+++ [pyenv:34] true
++ [pyenv:34] path=
++ [pyenv:31] '[' -n '' ']'
++ [pyenv:37] pwd
++ [pyenv:38] cd /Users/meng
+ [pyenv:63] bin_path=/usr/local/Cellar/pyenv/20141012/libexec
+ [pyenv:64] for plugin_bin in '"${PYENV_ROOT}/plugins/"*/bin'
+ [pyenv:65] bin_path=/usr/local/Cellar/pyenv/20141012/libexec:/usr/local/opt/pyenv/plugins/python-build/bin
+ [pyenv:67] export PATH=/usr/local/Cellar/pyenv/20141012/libexec:/usr/local/opt/pyenv/plugins/python-build/bin:/Users/meng/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/pyenv/shims:/Users/meng/bin:/usr/local/sbin
+ [pyenv:67] PATH=/usr/local/Cellar/pyenv/20141012/libexec:/usr/local/opt/pyenv/plugins/python-build/bin:/Users/meng/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/pyenv/shims:/Users/meng/bin:/usr/local/sbin
+ [pyenv:69] hook_path=:/usr/local/opt/pyenv/pyenv.d:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib/pyenv/hooks
+ [pyenv:73] export PYENV_HOOK_PATH=:/usr/local/opt/pyenv/pyenv.d:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib/pyenv/hooks
+ [pyenv:73] PYENV_HOOK_PATH=:/usr/local/opt/pyenv/pyenv.d:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib/pyenv/hooks
+ [pyenv:75] shopt -u nullglob
+ [pyenv:78] command=prefix
+ [pyenv:79] case "$command" in
++ [pyenv:87] command -v pyenv-prefix
+ [pyenv:87] command_path=/usr/local/Cellar/pyenv/20141012/libexec/pyenv-prefix
+ [pyenv:88] '[' -z /usr/local/Cellar/pyenv/20141012/libexec/pyenv-prefix ']'
+ [pyenv:93] shift 1
+ [pyenv:94] exec /usr/local/Cellar/pyenv/20141012/libexec/pyenv-prefix
+ [pyenv-prefix:13] '[' '' = --complete ']'
+ [pyenv-prefix:18] '[' -n '' ']'
+ [pyenv-prefix:24] '[' -z '' ']'
++ [pyenv-prefix:25] pyenv-version-name
+ [pyenv-version-name:6] '[' -z '' ']'
++ [pyenv-version-name:7] pyenv-version-file
+ [pyenv-version-file:21] find_local_version_file /Users/meng
+ [pyenv-version-file:7] local root=/Users/meng
+ [pyenv-version-file:8] '[' -n /Users/meng ']'
+ [pyenv-version-file:9] '[' -e /Users/meng/.python-version ']'
+ [pyenv-version-file:12] '[' -e /Users/meng/.pyenv-version ']'
+ [pyenv-version-file:16] '[' /Users/meng = /Users ']'
+ [pyenv-version-file:17] root=/Users
+ [pyenv-version-file:8] '[' -n /Users ']'
+ [pyenv-version-file:9] '[' -e /Users/.python-version ']'
+ [pyenv-version-file:12] '[' -e /Users/.pyenv-version ']'
+ [pyenv-version-file:16] '[' /Users = '' ']'
+ [pyenv-version-file:17] root=
+ [pyenv-version-file:8] '[' -n '' ']'
+ [pyenv-version-file:22] '[' /Users/meng = /Users/meng ']'
+ [pyenv-version-file:24] global_version_file=/usr/local/opt/pyenv/version
+ [pyenv-version-file:26] '[' -e /usr/local/opt/pyenv/version ']'
+ [pyenv-version-file:27] echo /usr/local/opt/pyenv/version
+ [pyenv-version-name:7] PYENV_VERSION_FILE=/usr/local/opt/pyenv/version
++ [pyenv-version-name:8] pyenv-version-file-read /usr/local/opt/pyenv/version
+ [pyenv-version-file-read:6] VERSION_FILE=/usr/local/opt/pyenv/version
+ [pyenv-version-file-read:8] '[' -e /usr/local/opt/pyenv/version ']'
+ [pyenv-version-file-read:11] IFS='
'
+ [pyenv-version-file-read:12] words=($(cut -b 1-1024 "$VERSION_FILE" | $(type -p gawk awk | head -1) '{ print($1) }'))
++ [pyenv-version-file-read:12] cut -b 1-1024 /usr/local/opt/pyenv/version
+++ [pyenv-version-file-read:12] type -p gawk awk
+++ [pyenv-version-file-read:12] head -1
++ [pyenv-version-file-read:12] /usr/bin/awk '{ print($1) }'
+ [pyenv-version-file-read:13] versions=("${words[@]}")
+ [pyenv-version-file-read:15] '[' -n system ']'
+ [pyenv-version-file-read:16] IFS=:
+ [pyenv-version-file-read:17] echo system
+ [pyenv-version-file-read:18] exit
+ [pyenv-version-name:8] PYENV_VERSION=system
+ [pyenv-version-name:11] '[' -z system ']'
+ [pyenv-version-name:11] '[' system = system ']'
+ [pyenv-version-name:12] echo system
+ [pyenv-version-name:13] exit
+ [pyenv-prefix:25] PYENV_VERSION=system
+ [pyenv-prefix:28] PYENV_PREFIX_PATHS=()
+ [pyenv-prefix:29] OLDIFS='
'
+ [pyenv-prefix:30] IFS=:
+ [pyenv-prefix:31] for version in '${PYENV_VERSION}'
+ [pyenv-prefix:32] '[' system = system ']'
++ [pyenv-prefix:33] pyenv-which python
+ [pyenv-prefix:33] PYTHON_PATH=/usr/bin/python
+ [pyenv-prefix:34] PYENV_PREFIX_PATH=/usr
+ [pyenv-prefix:42] '[' -d /usr ']'
+ [pyenv-prefix:43] PYENV_PREFIX_PATHS=("${PYENV_PREFIX_PATHS[@]}" "$PYENV_PREFIX_PATH")
+ [pyenv-prefix:50] IFS='
'
+ [pyenv-prefix:52] OLDIFS='
'
+ [pyenv-prefix:53] IFS=:
+ [pyenv-prefix:54] echo /usr
+ [pyenv-prefix:56] IFS='
'
++ [pyenv:15] type -p greadlink readlink
++ [pyenv:15] head -1
+ [pyenv:15] READLINK=/usr/bin/readlink
+ [pyenv:16] '[' -z /usr/bin/readlink ']'
+ [pyenv:21] unset GREP_OPTIONS
+ [pyenv:41] '[' -z /usr/local/opt/pyenv ']'
+ [pyenv:44] PYENV_ROOT=/usr/local/opt/pyenv
+ [pyenv:46] export PYENV_ROOT
+ [pyenv:48] '[' -z '' ']'
++ [pyenv:49] pwd
+ [pyenv:49] PYENV_DIR=/Users/meng
+ [pyenv:58] export PYENV_DIR
+ [pyenv:61] shopt -s nullglob
++ [pyenv:63] abs_dirname /usr/local/bin/pyenv
+++ [pyenv:28] pwd
++ [pyenv:28] local cwd=/Users/meng
++ [pyenv:29] local path=/usr/local/bin/pyenv
++ [pyenv:31] '[' -n /usr/local/bin/pyenv ']'
++ [pyenv:32] cd /usr/local/bin
++ [pyenv:33] local name=pyenv
+++ [pyenv:34] resolve_link pyenv
+++ [pyenv:24] /usr/bin/readlink pyenv
++ [pyenv:34] path=../Cellar/pyenv/20141012/bin/pyenv
++ [pyenv:31] '[' -n ../Cellar/pyenv/20141012/bin/pyenv ']'
++ [pyenv:32] cd ../Cellar/pyenv/20141012/bin
++ [pyenv:33] local name=pyenv
+++ [pyenv:34] resolve_link pyenv
+++ [pyenv:24] /usr/bin/readlink pyenv
++ [pyenv:34] path=../libexec/pyenv
++ [pyenv:31] '[' -n ../libexec/pyenv ']'
++ [pyenv:32] cd ../libexec
++ [pyenv:33] local name=pyenv
+++ [pyenv:34] resolve_link pyenv
+++ [pyenv:24] /usr/bin/readlink pyenv
+++ [pyenv:34] true
++ [pyenv:34] path=
++ [pyenv:31] '[' -n '' ']'
++ [pyenv:37] pwd
++ [pyenv:38] cd /Users/meng
+ [pyenv:63] bin_path=/usr/local/Cellar/pyenv/20141012/libexec
+ [pyenv:64] for plugin_bin in '"${PYENV_ROOT}/plugins/"*/bin'
+ [pyenv:65] bin_path=/usr/local/Cellar/pyenv/20141012/libexec:/usr/local/opt/pyenv/plugins/python-build/bin
+ [pyenv:67] export PATH=/usr/local/Cellar/pyenv/20141012/libexec:/usr/local/opt/pyenv/plugins/python-build/bin:/Users/meng/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/pyenv/shims:/Users/meng/bin:/usr/local/sbin
+ [pyenv:67] PATH=/usr/local/Cellar/pyenv/20141012/libexec:/usr/local/opt/pyenv/plugins/python-build/bin:/Users/meng/bin:/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/opt/pyenv/shims:/Users/meng/bin:/usr/local/sbin
+ [pyenv:69] hook_path=:/usr/local/opt/pyenv/pyenv.d:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib/pyenv/hooks
+ [pyenv:73] export PYENV_HOOK_PATH=:/usr/local/opt/pyenv/pyenv.d:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib/pyenv/hooks
+ [pyenv:73] PYENV_HOOK_PATH=:/usr/local/opt/pyenv/pyenv.d:/usr/local/etc/pyenv.d:/etc/pyenv.d:/usr/lib/pyenv/hooks
+ [pyenv:75] shopt -u nullglob
+ [pyenv:78] command=sh-activate
+ [pyenv:79] case "$command" in
++ [pyenv:87] command -v pyenv-sh-activate
+ [pyenv:87] command_path=/usr/local/bin/pyenv-sh-activate
+ [pyenv:88] '[' -z /usr/local/bin/pyenv-sh-activate ']'
+ [pyenv:93] shift 1
+ [pyenv:94] exec /usr/local/bin/pyenv-sh-activate --no-error --verbose
+ [pyenv-sh-activate:17] unset NOERROR
+ [pyenv-sh-activate:18] unset VERBOSE
+ [pyenv-sh-activate:20] '[' 2 -gt 0 ']'
+ [pyenv-sh-activate:21] case "$1" in
+ [pyenv-sh-activate:28] NOERROR=1
+ [pyenv-sh-activate:41] shift 1
+ [pyenv-sh-activate:20] '[' 1 -gt 0 ']'
+ [pyenv-sh-activate:21] case "$1" in
+ [pyenv-sh-activate:35] VERBOSE=1
+ [pyenv-sh-activate:41] shift 1
+ [pyenv-sh-activate:20] '[' 0 -gt 0 ']'
+ [pyenv-sh-activate:44] versions=("$@")
+ [pyenv-sh-activate:45] '[' -z '' ']'
+ [pyenv-sh-activate:46] no_shell=1
+ [pyenv-sh-activate:47] OLDIFS='
'
+ [pyenv-sh-activate:48] IFS=:
+ [pyenv-sh-activate:48] versions=($(pyenv-version-name))
++ [pyenv-sh-activate:48] pyenv-version-name
+ [pyenv-version-name:6] '[' -z '' ']'
++ [pyenv-version-name:7] pyenv-version-file
+ [pyenv-version-file:21] find_local_version_file /Users/meng
+ [pyenv-version-file:7] local root=/Users/meng
+ [pyenv-version-file:8] '[' -n /Users/meng ']'
+ [pyenv-version-file:9] '[' -e /Users/meng/.python-version ']'
+ [pyenv-version-file:12] '[' -e /Users/meng/.pyenv-version ']'
+ [pyenv-version-file:16] '[' /Users/meng = /Users ']'
+ [pyenv-version-file:17] root=/Users
+ [pyenv-version-file:8] '[' -n /Users ']'
+ [pyenv-version-file:9] '[' -e /Users/.python-version ']'
+ [pyenv-version-file:12] '[' -e /Users/.pyenv-version ']'
+ [pyenv-version-file:16] '[' /Users = '' ']'
+ [pyenv-version-file:17] root=
+ [pyenv-version-file:8] '[' -n '' ']'
+ [pyenv-version-file:22] '[' /Users/meng = /Users/meng ']'
+ [pyenv-version-file:24] global_version_file=/usr/local/opt/pyenv/version
+ [pyenv-version-file:26] '[' -e /usr/local/opt/pyenv/version ']'
+ [pyenv-version-file:27] echo /usr/local/opt/pyenv/version
+ [pyenv-version-name:7] PYENV_VERSION_FILE=/usr/local/opt/pyenv/version
++ [pyenv-version-name:8] pyenv-version-file-read /usr/local/opt/pyenv/version
+ [pyenv-version-file-read:6] VERSION_FILE=/usr/local/opt/pyenv/version
+ [pyenv-version-file-read:8] '[' -e /usr/local/opt/pyenv/version ']'
+ [pyenv-version-file-read:11] IFS='
'
+ [pyenv-version-file-read:12] words=($(cut -b 1-1024 "$VERSION_FILE" | $(type -p gawk awk | head -1) '{ print($1) }'))
++ [pyenv-version-file-read:12] cut -b 1-1024 /usr/local/opt/pyenv/version
+++ [pyenv-version-file-read:12] type -p gawk awk
+++ [pyenv-version-file-read:12] head -1
++ [pyenv-version-file-read:12] /usr/bin/awk '{ print($1) }'
+ [pyenv-version-file-read:13] versions=("${words[@]}")
+ [pyenv-version-file-read:15] '[' -n system ']'
+ [pyenv-version-file-read:16] IFS=:
+ [pyenv-version-file-read:17] echo system
+ [pyenv-version-file-read:18] exit
+ [pyenv-version-name:8] PYENV_VERSION=system
+ [pyenv-version-name:11] '[' -z system ']'
+ [pyenv-version-name:11] '[' system = system ']'
+ [pyenv-version-name:12] echo system
+ [pyenv-version-name:13] exit
+ [pyenv-sh-activate:49] IFS='
'
+ [pyenv-sh-activate:52] '[' -z 1 ']'
+ [pyenv-sh-activate:58] '[' 1 -gt 1 ']'
+ [pyenv-sh-activate:64] pyenv-virtualenv-prefix system
+ [pyenv-sh-activate:65] '[' -n 1 ']'
+ [pyenv-sh-activate:66] echo false
+ [pyenv-sh-activate:67] exit 1
from pyenv-virtualenv.
Related Issues (20)
- [FR] Local virtualvenvs + registering them / using them through `.python-version` HOT 14
- Force creating venv with same name doesn't update Python version
- Set CONDA_PROMPT_MODIFIER env var when activating conda environment HOT 5
- Env's name disappears from the prompt when spawning a subshell HOT 6
- python3-config (along with other tools) does not respect the version virtualenv hook on HOT 6
- pyenv deactivate doesn't deactivate env HOT 1
- pyenv virtualenv does not correctly link the c++ libraries associated to the python package HOT 1
- New release? HOT 3
- Latest version HOT 1
- Incorrect version reported by `pyenv virtualenv --version` HOT 1
- Cannot create new virtualenv with "system" Python if it's 3.11+ HOT 1
- Hooks for virtualenv-delete HOT 1
- Hooks don't work under /usr/share/pyenv/plugins
- Virtualenv not isolated HOT 1
- Don't use `.python-version` for auto-activation HOT 3
- "tox: command not found" despite tox being present in the active environment HOT 1
- Unable to use `venv/bin/activate` when the virtual environment of pyenv-virtualenv is set. HOT 2
- virtualenv-init break mc (Midnight Commander) subshell
- `_pyenv_virtualenv_hook` still in $PROMPT_COMMAND after uninstall HOT 3
- weird cyclic symlink on macos HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyenv-virtualenv.