Python Virtualenv - Ningún módulo llamado virtualenvwrapper.cargador de gancho


Estoy ejecutando Mac OS 10.6.8. y quería instalar además de python 2.6 también python 2.7 y usar python 2.7 en un nuevo virtualenv. Ejecuté los siguientes pasos:

He descargado python 2.7 e instalado:

http://www.python.org/ftp/python/2.7.3/python-2.7.3-macosx10.6.dmg

Luego corro el comando para configurar un nuevo virtualenv usando python2. 7:

mkvirtualenv --python=python2.7 mynewenv

My .bash_profile tiene el siguiente aspecto:

# needed for virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python
export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv
source /usr/local/bin/virtualenvwrapper.sh


# Setting PATH for Python 2.7
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/2.7/bin:${PATH}"
export PATH

Ahora cuando abro la consola recibo el siguiente mensaje de error.

ImportError: No module named virtualenvwrapper.hook_loader
virtualenvwrapper.sh: There was a problem running the initialization hooks. If Python could not import the module virtualenvwrapper.hook_loader, check that virtualenv has been installed for VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python and that PATH is set properly.

También encontré en un diferente publicar que debo actualizar virtualenvwrapper. Eso no ayudó.

sudo pip install virtualenvwrapper --upgrade

Cualquier ayuda sería apreciada.

Author: Thomas Kremmel, 2012-07-16

14 answers

El problema se resolvió siguiendo los siguientes pasos:

#switch the /usr/bin/python link to point to current python link
cd /usr/bin
sudo mv python python.bak
sudo ln -s /Library/Frameworks/Python.framework/Versions/Current/bin/python python

Reorganice el comando export para que se coloque antes de los comandos virtualenv en my .archivo bash_profile:

PATH=/Library/Frameworks/Python.framework/Versions/2.7/bin:$PATH
export PATH

# needed for virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh

Vuelva a instalar setuptools, easy install y PIP. Esto es obviamente necesario para que funcionen correctamente con la nueva versión de python:

sudo sh setuptools-0.6c11-py2.7.egg

sudo easy_install-2.7 pip

pip install virtualenv
 50
Author: Thomas Kremmel,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-22 12:42:57

Además, si tiene macports, asegúrese de que /opt/local/Library/Frameworks/Python.framework/Versions/2.7/bin aparece antes de /Library/Frameworks/Python.framework/Versions/2.7/bin y /usr/local/bin en PATH. Luego establece lo siguiente en ti .profile:

export VIRTUALENVWRAPPER_PYTHON=`which python`
export VIRTUALENVWRAPPER_VIRTUALENV=`which virtualenv`
source `which virtualenvwrapper.sh`
 18
Author: reubano,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-09-05 05:00:25

En mi caso, añadiendo esta línea en mi.archivo zshrc hizo el truco,

export VIRTUALENVWRAPPER_PYTHON=/usr/local/Cellar/python/2.7.13/bin/python2.7
 6
Author: pecai,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-04-21 18:03:48

Esto me sucedió y lo resolví reinstalando pip. Lo que había sucedido era que which pip dio /usr/bin/pip como resultado, mientras que which python dio /usr/local/bin/python. La ruta para pip debe ser /usr/local/bin/pip. Esto probablemente se rompió cuando actualizé mi instalación de Python.

Si sigue la documentación pip puede reinstalar fácilmente pip para su configuración actual de Python. Necesitas:

  1. Descargar el get-pip.py script (directamente vinculado desde pip's documentación).
  2. Ejecutar python get-pip.py.

Esto resolvió el problema para mí.

 3
Author: Omar Trejo,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2015-04-21 03:58:32

Hay una serie de cosas que pueden causar este error. Si su entorno es

  • CentOS 7, con python3 instalado desde epel-release
  • pip3 instalado con python3.4 get-pip.py
  • virtualenvwrapper instalado con pip3
  • Un entorno virtual de python hecho con mkvirtualenv -p /usr/bin/python3.4

Entonces, por cualquier razón, el entorno virtual se crea sin la biblioteca virtualenvwrapper. Puede resolverlo simplemente instalándolo de nuevo, pero esta vez desde dentro del virtlualenv

[user@localhost ~] $ mkvirtualenv -p /usr/bin/python3.4 venv
Using base prefix '/usr'
New python executable in /home/user/.virtualenvs/venv/bin/python3.4
Also creating executable in /home/user/.virtualenvs/venv/bin/python
Installing setuptools, pip, wheel...done.
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/venv/bin/predeactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/venv/bin/postdeactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/venv/bin/preactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/venv/bin/postactivate
virtualenvwrapper.user_scripts creating /home/user/.virtualenvs/venv/bin/get_env_details
/home/user/.virtualenvs/venv/bin/python3.4: Error while finding spec for 'virtualenvwrapper.hook_loader' (<class 'ImportError'>: No module named 'virtualenvwrapper')
/home/user/.virtualenvs/venv/bin/python3.4: Error while finding spec for 'virtualenvwrapper.hook_loader' (<class 'ImportError'>: No module named 'virtualenvwrapper')

# the virtualenv should now activated
(venv)[user@localhost ~] $ pip install virtualenvwrapper
 2
Author: drs,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-01-27 17:02:45

Solo tenía que asegurarme de que /usr/local/bin/python existía.

Para mí fue un simple:

ln -s /usr/local/bin/python2.7 /usr/local/bin/python
 2
Author: dustinfarris,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-13 22:14:54

Obtengo el mismo error . Descubrí que tenía una versión antigua de Pip . Arreglé el error simplemente actualizando el pip .

 1
Author: Chinmay Das,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-12-04 08:27:28

Acabo de instalar python 3.5,probé el virtualenvwrapper y luego tuve este problema. Me di cuenta de que python3.5 estaba instalado en /usr/local/bin/python3.5 y NO en /usr/bin/python3.5. Así que revisé mi .bash_profile script para parecerse a la siguiente y todo parece funcionar ahora

# Setting PATH for Python 3.5
# The orginal version is saved in .bash_profile.pysave
PATH="/Library/Frameworks/Python.framework/Versions/3.5/bin:${PATH}"
export PATH
export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python3.5
export WORKON_HOME=$HOME/.virtualenvs
source /Users/bentaub/.virtualenvs/djangodev/bin/virtualenvwrapper.sh

Soy lo suficientemente novato como para no estar seguro de cómo ese 'local' en el camino a python3.5 va a afectarme a largo plazo, pero, por ahora, funciona.

 0
Author: Ben,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-01-23 20:54:10

Tuve este problema después de desinstalar el paquete virtualenvwrapper. Cuando me conectaba a cualquier usuario (o su a uno diferente), obtenía:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
ImportError: No module named virtualenvwrapper.hook_loader                                                                                                                                                                       
virtualenvwrapper.sh: There was a problem running the initialization hooks.                                                                                                                                                      

If Python could not import the module virtualenvwrapper.hook_loader,                                                                                                                                                             
check that virtualenv has been installed for                                                                                                                                                                                     
VIRTUALENVWRAPPER_PYTHON=/usr/bin/python and that PATH is                                                                                                                                                                        
set properly.

La solución fue eliminar el archivo /etc/bash_completion.d/virtualenvwrapper.

Editar:

No elimine el archivo anterior o no se volverá a crear si vuelve a instalar virtualenvwrapper. En su lugar, lo que debe hacer es purge el paquete virtualenvwrapper cuando lo desinstale. Así en Debian:

apt-get remove --purge virtualenvwrapper
 0
Author: Mike,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-07-06 21:07:19

Intente desinstalar su virtualenv y virtualenvwrapper e instálelo de nuevo usando pip en la versión 2.7 (creo).

Me encontré con el mismo error y acabo de hacer esto y resuelto mi problema.

I usando U

 0
Author: manilaT,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-01-18 05:33:28

A pesar de que hay una respuesta aceptada, pensé que pondría lo que la arregló para mí.

En primer lugar instalé Python y acababa de actualizarlo a través de Homebrew. También estoy usando ZSH, por lo que si algunos bits no coinciden con su salida, podría ser por eso.

Ejecutando brew info python y mirando a través de la salida encontré la siguiente información:

If you wish to have this formula's python executable in your PATH then add
the following to ~/.zshrc:
    export PATH="/usr/local/opt/python/libexec/bin:$PATH"

Así que agregué esto a mi script de inicio de terminal como se muestra y el error n Mostrar.

Nota: Inserté esto en otra parte de mi RUTA y el error persistió al iniciar.

 0
Author: Skepi,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-08-23 14:55:47

Se encontró con un problema similar después de instalar el proyecto Conda/Anaconda. Esta pregunta fue bastante útil para resolver mi problema en MAC.Para resolver el problema, mi .zshrc porción relevante se veía así:

export VIRTUALENVWRAPPER_PYTHON=$HOME/Applications/conda/bin/python
source $HOME/Applications/conda/bin/virtualenvwrapper.sh

Esto depende de dónde tengo instalado conda y tendrás que calcularlo en tu propio caso. Para obtener los detalles para su entorno dado, dependiendo de dónde haya instalado anaconda, puede usar lo siguiente:

$  ~/ -name virtualenvwrapper.sh # to see where you have this. May already be prefilled in your shell profile[.zshrc or .profile]

$ which python   # to know the default python your project or rather where conda has installed python for you

NO SE OLVIDE DE DESINSTALAR E INSTALAR virtualenv y virtualenvwrapper como se destaca en otras respuestas.

 0
Author: ArdentLearner,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-01-22 15:45:22

Acaba de toparse con este problema en un Centos 7.4.

Ninguna de las respuestas anteriores se adaptaba a mi caso. Después de un poco de investigación, señalé esto como permisos de archivo demasiado estrictos en las bibliotecas de python (supongo que la instalación de python en Centos difiere un poco de otros sistemas POSIX).

Por lo tanto, si todo lo demás falla, es posible que desee verificar que sus bibliotecas de python sean legibles por el usuario con el que está tratando de ejecutar virtualenvwrapper.

En particular, comprobar: /usr/lib/python3.6 /usr/lib64/python3.6 (modificar las rutas para diferentes versiones de python).

Si ves que group y others carecen de permisos de lectura y ejecución, entonces agrégalos: sudo chmod og+rx -R /usr/lib/python3.6 sudo chmod og+rx -R /usr/lib64/python3.6

Nota: No estoy seguro de si esto funciona en contra de una política de seguridad de Centos, pero probablemente es seguro siempre y cuando no se da write persmisions.

 0
Author: ,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-28 10:05:10

En mi situación (OS X 10.13.6), esto lo hizo

brew install python2 --upgrade
 0
Author: Jay,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-09-15 18:15:25