Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check which Python interpreter Spyder is running on its console?

Tags:

python

spyder

The question:

This post explains how to change which Python installation to run in Spyder under Tools > Preferences > Python Interpreter. One of the options is Default (i.e. same as Spyder's):

enter image description here

But how do you find out what that is?

Some details:

I'm trying to help a colleague run a Python script using a batch file. The script runs just fine from Spyder. But when I'm setting up the batch file, I'm getting the error error importing module Seaborn. So I'm clearly able to run Python (the only python.exe I've found on the system) with the batch setup, but the importing error makes me think that there are more Python installations on the system that I'm not able to detect for some reason, but is being used by Spyder since the very same script does not raise the same error when run from Spyder. I'm a bit confused here, so thank you for any suggestions!

like image 861
vestland Avatar asked Jan 17 '19 11:01

vestland


People also ask

Which Python interpreter is Spyder using?

If I launch Spyder from the terminal by simply typing spyder , it will launch and I see that the Python interpreter is indeed the Python 3 from Anaconda, as shown below: Python 3.6.

How do I change the Python interpreter in Spyder?

To work with an existing environment in Spyder, you need to change Spyder's default Python interpreter. To do so, click the name of the current environment in the status bar, and then click Change default environment in Preferences. This will open the Preferences dialog in the Python interpreter section.

How do I know if Spyder is running?

In Spyder you can tell whether a script is running by looking at the small square in the top right of the console window. If a script is running its red, else its grey.

How do you get the Python Console on Spyder?

Go to Preferences -> IPython console -> Startup and select the tickbox next to Open an IPython console at startup. Then click the OK button. The next time Spyder starts, it will show the IPython console automatically.


1 Answers

(Spyder maintainer here) To detect the interpreter run by our IPython consoles, you need to run the following code on any of them:

In [1]: import sys                                                                                                                                                         

In [2]: sys.executable                                                                                                                                                     
Out[2]: '/home/carlos/miniconda/envs/py36/bin/python'
like image 101
Carlos Cordoba Avatar answered Sep 20 '22 11:09

Carlos Cordoba