Intento ejecutar un shell de Django en IPython:
ipython manage.py shellInforma el siguiente error:
Escriba 'manage.py help' para obtener ayuda sobre un subcomando específico.
Busqué y encontré una solución popular que lo guía para instalar django.extensions y habilitarlo en la settings .
Estoy creando un proyecto mínimo mientras que la solución es pesada. Mientras tanto, tengo que instalarlo y habilitarlo en cada proyecto.
¿Hay una manera ligera?
Comienzo un nuevo proyecto, python manage.py shell -i ipython no funciona
$ python manage.py shell -i ipython CommandError: Couldn't import ipython interface. $ ipython --version 6.4.0Agradezco la respuesta anterior y, en base a eso, he escrito esta respuesta.
Si ipython ya está instalado en su virtualenv , cualquiera de los siguientes comandos funcionará igual (que ya se presentó a continuación después de los comandos con fragmentos de muestra, puntualmente).
python manage.py shellpython manage.py -i ipythonHow I solved (steps with problem & solution)?Nota: asegúrese de que ya ha activado su
virtualenv.
1) No tenía ipython instalado en mi proyecto Django. A continuación se muestra el error que recibí al intentar ejecutar Django shell en un entorno ipython .
(venv3.6.7) Rishikeshs-MacBook-Air:src hygull$ python manage.py shell -i ipython CommandError: Couldn't import ipython interface. (venv3.6.7) Rishikeshs-MacBook-Air:src hygull$ Luego instalé ipython usando el siguiente comando.
2) pip install ipython
(venv3.6.7) Rishikeshs-MacBook-Air:src hygull$ pip install ipython Collecting ipython Downloading https://files.pythonhosted.org/packages/05/d7/77b7a1988c99227f52402f93fb0f7e88c97239960516f53907ebbc44149c/ipython-7.11.0-py3-none-any.whl (777kB) ... ... |████████████████████████████████| 102kB 524kB/s Installing collected packages: ipython-genutils, six, decorator, traitlets, pygments, ptyprocess, pexpect, wcwidth, prompt-toolkit, backcall, parso, jedi, appnope, pickleshare, ipython Successfully installed appnope-0.1.0 backcall-0.1.0 decorator-4.4.1 ipython-7.11.0 ipython-genutils-0.2.0 jedi-0.15.2 parso-0.5.2 pexpect-4.7.0 pickleshare-0.7.5 prompt-toolkit-3.0.2 ptyprocess-0.6.0 pygments-2.5.2 six-1.13.0 traitlets-4.3.3 wcwidth-0.1.7 (venv3.6.7) Rishikeshs-MacBook-Air:src hygull$ 3.a) python manage,py shell -i ipython
(venv3.6.7) Rishikeshs-MacBook-Air:src hygull$ python manage.py shell -i ipython Python 3.6.7 (v3.6.7:6ec5cf24b7, Oct 20 2018, 03:02:14) Type 'copyright', 'credits' or 'license' for more information IPython 7.11.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: exit() 3.b) python manage.py shell
(venv3.6.7) Rishikeshs-MacBook-Air:src hygull$ python manage.py shell Python 3.6.7 (v3.6.7:6ec5cf24b7, Oct 20 2018, 03:02:14) Type 'copyright', 'credits' or 'license' for more information IPython 7.11.0 -- An enhanced Interactive Python. Type '?' for help. In [1]:Gracias.
Simplemente instale ipython en su virtualenv. manage.py shell debería usarlo de forma predeterminada.
También puede usar manage.py shell con la opción -i para seleccionar explícitamente un shell (las opciones son ipython , bpython o python para un shell de Python normal):
python manage.py shell -i ipython De cualquier manera, necesita instalar ipython en su entorno, pero no necesita realizar ningún cambio en la configuración de su proyecto.