Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

288
Views
pyenv ya no establece rutas correctamente al activar entornos virtuales

He estado usando pyenv durante casi dos años sin problemas en mi sistema que ejecuta RHEL 8.3 (Linux kernel 4.18) con Gnome 3.32.2 en modo X11. Principalmente uso el caparazón de pescado, pero también ocasionalmente bash, ambos funcionaron bien con pyenv hasta ahora. Sin embargo, después de ejecutar pyenv update hace aproximadamente 24 horas, usar el comando de activación de pyenv activate para activar uno de mis entornos virtuales creados ya no establece la ruta para usar lo que he instalado en ese entorno virtual.

Cuando inicio una sesión de terminal, veo un nuevo mensaje que dice:

 WARNING: `pyenv init -` no longer sets PATH. Run `pyenv init` to see the necessary changes to make to your configuration.

Así que ejecuté pyenv init que me dijo:

 # Add pyenv executable to PATH by adding # the following to ~/.profile: set -Ux PYENV_ROOT $HOME/.pyenv set -Ux fish_user_paths $PYENV_ROOT/bin $fish_user_paths # Load pyenv automatically by appending # the following to ~/.config/fish/config.fish: pyenv init - | source # and the following to ~/.profile: pyenv init --path | source # If your ~/.profile sources ~/.config/fish/config.fish, # the lines should be inserted before the part # that does that. # Make sure to restart your entire logon session # for changes to ~/.profile to take effect.

Estoy bastante seguro de que ya tengo todo lo anterior. Aquí está mi ~/.profile :

 set -Ux PYENV_ROOT $HOME/.pyenv set -Ux fish_user_paths $PYENV_ROOT/bin $fish_user_paths pyenv init --path | source

Aquí está mi ~/.config/fish/config.fish :

 # Set default editor set -gx EDITOR nano # Set Junest path set PATH /home/[username]/.local/share/junest/bin $PATH # Set pyenv root directory set PYENV_ROOT $HOME/.pyenv # Add pyenv and local bin to $PATH set PATH $PYENV_ROOT/bin /home/[username]/.local/bin $PATH # Add pyenv init to shell to enable shims and autocompletion # Note the command `pyenv init` will tell you to add this line for fish status --is-interactive; and source (pyenv init -|psub) pyenv init - | source

Mi ~/.bashrc :

 # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi # User specific environment PATH="$HOME/.local/bin:$HOME/bin:$PATH" export PATH # Uncomment the following line if you don't like systemctl's auto-paging featur$ # export SYSTEMD_PAGER= # User specific aliases and functions # Load pyenv export PATH="$HOME/.pyenv/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)"

Algunas observaciones más:

  1. Descubrí que a pesar de que tengo ~/.profile , nunca se obtiene/ejecuta cuando inicio sesión en mi entorno de escritorio.
  2. Poner set -Ux PYENV_ROOT $HOME/.pyenv y set -Ux fish_user_paths $PYENV_ROOT/bin $fish_user_paths en ~/.profile o ~/.config/fish/config.fish no hace la diferencia.

Al final, incluso después de activar un entorno virtual creado por pyenv, todavía no tengo acceso a lo que contiene.

¿Cómo puedo solucionar esto? Gracias.

over 4 years ago · Hanz Gallego
5 answers
Answer question

0

El mensaje está mal. ~/.profile es para shells compatibles con posix, que fish no lo es, por lo que no lo leerá. Esto debe informarse como un error en pyenv.

Ahora, ya tiene el código para agregar a $PATH en su config.fish, por lo que parece que no es necesaria ninguna otra acción de su parte, la advertencia no se aplica a usted.

Su ~/.profile es un código de pescado, que es incompatible con los shells que lo leerán y sugiero eliminarlo.


Si aún no tenía todos los bits necesarios:

Curiosamente, el código real es compatible con fish (excepto pyenv init --path , que imprime el código posix. Sugiero omitirlo). Dado que recomienda usar variables universales a través de set -U , y esas persisten, solo querrá ejecutar set -U una vez de forma interactiva :

 set -Ux PYENV_ROOT $HOME/.pyenv set -Ux fish_user_paths $PYENV_ROOT/bin $fish_user_paths

No desea agregarlos en config.fish. Fish persiste en las variables universales y esta se agrega a $fish_user_paths, por lo que agregará un componente cada vez que abra un pez, lo que terminará dejándolo con cientos de elementos y ralentizará a Fish.

Alternativamente, agregue $PYENV_ROOT/bin a $PATH usted mismo en config.fish, al igual que las adiciones de $PATH que ya está haciendo:

 # Set pyenv root directory set -gx PYENV_ROOT $HOME/.pyenv # (note that this must now come later because it uses $PYENV_ROOT) set -gx PATH /home/[username]/.local/share/junest/bin $PYENV_ROOT/bin $PATH

(o use fish_add_path , enviado en fish 3.2 - fish_add_path /home/[username]/.local/share/junest/bin $PYENV_ROOT/bin - esto se encargará de no agregarlo varias veces)

Mantenga el inicio de pyenv init - | source (que termina haciendo lo mismo que source (pyenv init -|psub) sin un archivo temporal inútil, por lo que es preferible)

over 4 years ago · Hanz Gallego Report

0

Para aquellos que han llegado a esta pregunta y están usando algo más que pescado, también traté de seguir las instrucciones dadas por pyenv -init sin éxito. Como @jmunsch, tengo Ubuntu 20.04 y bash. Sin embargo, parece que ~/.profile no se está leyendo o algo en mi configuración de bash está sobrescribiendo la configuración relevante de ~/.profile antes pyenv -init se ejecute. No tengo idea de qué puede ser esto, pero antes de que alguien pregunte:

  1. Sí, los cambios ~/.profile se establecieron antes de la línea que origina ~/.bashrc
  2. No, no uso ~/.bash_profile o ~/.bash_login

Esto es lo que hice en su lugar, TODO en ~/.bashrc :

 export PYENV_ROOT=$HOME/.pyenv export PATH=$PYENV_ROOT/bin:$PATH # <Other commands not relevant to pyenv - jump straight to evals if you like> # . # . eval "$(pyenv init --path)" eval "$(pyenv init -)"

No probé pyenv exhaustivamente, pero la advertencia desapareció y parece funcionar bien.

over 4 years ago · Hanz Gallego Report

0

Sistema operativo: ubuntu 18.04

pyenv por

 pyenv update

y comienza a mostrar esta advertencia

 WARNING: `pyenv init -` no longer sets PATH. Run `pyenv init` to see the necessary changes to make to your configuration.

y pyenv ya no establece la ruta correctamente

REPARAR

Tengo estas líneas en mi ~/.bashrc . Por lo tanto, elimine o comente estas líneas si las tiene en ~/.bashrc

 export PATH="/home/yogi/.pyenv/bin:$PATH" eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)"

Agregue estas líneas en ~/.profile antes de obtener ~/.bashrc

 export PYENV_ROOT="$HOME/.pyenv" export PATH="$PYENV_ROOT/bin:$PATH" eval "$(pyenv init --path)"

Perfil de origen

 source ~/.profile
over 4 years ago · Hanz Gallego Report

0

Simplemente reemplace la línea eval "$(pyenv init -)" de su archivo ~/.bashrc por eval "$(pyenv init --path)" .

Consulte este problema: https://github.com/pyenv/pyenv/issues/1906

over 4 years ago · Hanz Gallego Report

0

Para Mac y fish, agregue esto a ~/.config/fish/config.fish :

 set PYENV_ROOT $HOME/.pyenv set -x PATH $PYENV_ROOT/shims $PATH set -x PATH $PYENV_ROOT/bin $PATH if command -v pyenv 1>/dev/null 2>&1 pyenv init - | source end
over 4 years ago · Hanz Gallego Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!