11

I have installed Spyder on Linux (Mint 17 to be exact) and created a scientific virtualenv (sci) with ipython, numpy, etc. The idea is to vary my virtual env for python 2 / python 3 and being a bit more flexible than installing the whole of Anaconda / python(x,y). I am having problems getting ipython to work in Spyder now.

I went to

Tools->Preferences->Console->Advanced settings

Use the following Python interpreter

 /home/mike/envs/sci/bin/ipython

but this did not start ipython. It responds with

...
Execute the given command[TerminalIPythonApp] CRITICAL | Bad config     encountered during initialization:
[TerminalIPythonApp] CRITICAL | Unrecognized flag: '-u'
...

It also does not show "Open an IPython console" under Consoles.

any ideas what I am missing?

cheers, Mike

Mike
  • 3,775
  • 8
  • 39
  • 79
  • 2
    `Use the following Python interpreter` -> `/home/mike/envs/sci/bin/ipython`, well that's an `ipython` interpreter, not a `python` interpreter :) – cel Jan 28 '15 at 11:02
  • that's what I figured, but how to get the ipython up and running? Mike – Mike Jan 28 '15 at 12:49
  • Have you tried just entering `/home/mike/envs/sci/bin/python`? I cannot promise, but probably spyder will take care of starting `ipython`. – cel Jan 28 '15 at 12:52
  • @cel is right, you need to point to the python interpreter there. – Roberto Jan 28 '15 at 18:36

3 Answers3

7

After you correctly enter the path to the Python interpreter in your virtualenv (i.e. /home/mike/envs/sci/bin/python, not /home/mike/envs/sci/bin/ipython), you just need to go to the menu

Consoles > Open an IPython console

and, as long as you have IPython and PyQt/PySide installed in your virtualenv, an IPython console will be opened for you using the IPython version of your virtualenv.

Carlos Cordoba
  • 33,273
  • 10
  • 95
  • 124
  • 1
    `Tools->Preferences->Console->Advanced settings` no longer seems to have option to `Use the following Python interpreter` as of `spyder` v 3.1.3 under linux – Laurence Billingham Feb 22 '17 at 12:12
  • 2
    @LaurenceBillingham, that option was moved to `Tools > Preferences > Python interpreter` in Spyder 3. Sorry for the confusion. – Carlos Cordoba Feb 22 '17 at 14:58
2

the process is described in the following link :

https://github.com/spyder-ide/spyder/wiki/Working-with-packages-and-environments-in-Spyder

It is recommended to install a modular approach with spyder-kernels:

  1. activate the environment where you want to work (ex : source env/bin/activate)
  2. install the kernel in the environment by typing : pip install spyder-kernels==0.*
  3. get the interpreter path to be used by typing : python -c "import sys; print(sys.executable)"
  4. copy this path
  5. enter the path in Spyder in the menu

Preferences > Python Interpreter > Use the following interpreter

that should work, happy coding!

David
  • 49
  • 2
0

Solutions above didn't work for me. What worked for me was following this guide in the docs: https://docs.spyder-ide.org/ipythonconsole.html#connect-to-an-external-kernel

1) open terminal and activate your virtualenv 2) still in the terminal, run the command: python -m spyder_kernels.console, you will get a message like:

To connect another client to this kernel, use:
--existing kernel-28340.json

3) to locate this json file location, run this in spyder:

from jupyter_core import paths
paths.jupyter_runtime_dir()

for me it was c:\Users[myuser]\AppData\Roaming\jupyter\runtime\

4) In jupyter, from menu, click on "Consoles => Connect to an existing kernel"

justadev
  • 1,168
  • 1
  • 17
  • 32