virtualenvwrapper y Python 3


Instalé python 3.3.1 en ubuntu lucid y creé con éxito un virtualenv como se muestra a continuación

virtualenv envpy331 --python=/usr/local/bin/python3.3

Esto creó una carpeta envpy331 en mi directorio de inicio.

También tengo virtualenvwrapper instalado.Pero en los documentos solo se admiten las versiones 2.4-2.7 de python..¿Alguien ha intentado organizar el python3 virtualenv ? Si es así, ¿puedes decirme cómo ?

Author: Jonathan, 2013-04-20

8 answers

La última versión de virtualenvwrapper se prueba bajo Python3.2. Lo más probable es que funcione con Python3.3 también.

 19
Author: unutbu,
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-04-20 18:12:00

Si ya tienes python3 instalado así como virtualenvwrapper lo único que necesitas hacer para usar python3 con el entorno virtual es crear un entorno usando:

which python3 #Output: /usr/bin/python3
mkvirtualenv --python=/usr/bin/python3 nameOfEnvironment

O, (al menos en OSX usando brew):

mkvirtualenv --python=`which python3` nameOfEnvironment

Comience a usar el entorno y verá que tan pronto como escriba python comenzará a usar python3

 193
Author: Jonathan,
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-05-17 14:21:10

Puede hacer que virtualenvwrapper use un binario Python personalizado en lugar del que se ejecuta virtualenvwrapper. Para hacer eso necesitas usar la variable VIRTUALENV_PYTHON que es utilizada por virtualenv:

$ export VIRTUALENV_PYTHON=/usr/bin/python3
$ mkvirtualenv -a myproject myenv
Running virtualenv with interpreter /usr/bin/python3
New python executable in myenv/bin/python3
Also creating executable in myenv/bin/python
(myenv)$ python
Python 3.2.3 (default, Oct 19 2012, 19:53:16) 
[GCC 4.7.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 40
Author: Iliyan Bobev,
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-08-23 15:45:31

Virtualenvwrapper ahora le permite especificar el ejecutable de python sin la ruta.

Entonces (al menos en OSX)mkvirtualenv --python=python3 nameOfEnvironment será suficiente.

 18
Author: Peter Yin,
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-06-06 22:33:25

En Ubuntu; usando mkvirtualenv -p python3 env_name carga el virtualenv con python3.

Dentro del env, use python --version para verificar.

 14
Author: akashbw,
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-02-05 18:30:31

Encuentro que correr

export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python3

Y

export VIRTUALENVWRAPPER_VIRTUALENV=/usr/bin/virtualenv-3.4

En la línea de comandos de Ubuntu obliga a mkvirtualenv a usar python3 y virtualenv-3.4. Uno todavía tiene que hacer

mkvirtualenv --python=/usr/bin/python3 nameOfEnvironment

Para crear el entorno. Esto es asumiendo que tienes python3 en / usr / bin /python3 y virtualenv-3.4 en/usr/local/bin / virtualenv-3.4.

 8
Author: CuriousGeorge,
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-14 19:49:20

Puede agregar esto a su .bash_profile o similar:

alias mkvirtualenv3='mkvirtualenv --python=`which python3`'

Luego use mkvirtualenv3 en lugar de mkvirtualenv cuando desee crear un entorno python 3.

 8
Author: chorbs,
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-04-19 06:12:46

Este post en el bitbucket issue tracker de virtualenvwrapper puede ser de interés. Se menciona allí que la mayoría de las funciones de virtualenvwrapper funcionan con los entornos virtuales venv en Python 3.3.

 5
Author: Ioannis Filippidis,
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-06-19 09:25:54