Repository: spyder-ide/spyder

Issue:
ValueError: invalid literal for int() with base 10: b''
## Description

**What steps will reproduce the problem?**

1. 
2. 
3. 

**What is the expected output? What do you see instead?**


**Please provide any additional information below**

  File "/anaconda3/lib/python3.6/site-packages/spyder/plugins/maininterpreter.py", line 162, in python_executable_switched
    self.warn_python_compatibility(cust_pyexec)
  File "/anaconda3/lib/python3.6/site-packages/spyder/plugins/maininterpreter.py", line 171, in warn_python_compatibility
    console_version = int(proc.communicate()[0])
ValueError: invalid literal for int() with base 10: b''


## Version and main components

* Spyder Version: 3.2.3 
* Python Version: 3.6.2
* Qt Versions: 5.6.2, PyQt5 5.6 on Darwin

## Dependencies
```
pyflakes >=0.6.0 :  1.5.0 (OK)
pycodestyle >=2.3:  2.3.1 (OK)
pygments >=2.0   :  2.2.0 (OK)
pandas >=0.13.1  :  0.20.3 (OK)
numpy >=1.7      :  1.13.3 (OK)
sphinx >=0.6.6   :  1.6.3 (OK)
rope >=0.9.4     :  0.10.5 (OK)
jedi >=0.9.0     :  0.10.2 (OK)
psutil >=0.3     :  5.2.2 (OK)
nbconvert >=4.0  :  5.3.1 (OK)
sympy >=0.7.3    :  1.1.1 (OK)
cython >=0.21    :  0.26.1 (OK)
qtconsole >=4.2.0:  4.3.1 (OK)
IPython >=4.0    :  6.1.0 (OK)
pylint >=0.25    :  1.7.2 (OK)

```



Discussion:
`ValueError: invalid literal for int() with base 10: b''` Gives me a hint that a certain calculation is done using Log, Ln or Exp which is not correctly entered. Can you verify if this is the case?
Thanks for reporting. We'll take a look at this in a future release.
What also could be the case is that you are using an `int()` function on an empty string?
For example the following gives also the same error:
```
a = ""
int(a)
```
This error occurred when you tried to change the Python interpreter in the preferences.  Spyder tried to send code to the interpreter to get which version of Python it was using and instead didn't get an answer back.  @k78872, what interpreter were you trying to change to?  Do you get the same error every time you try to change to that interpreter or did this just happen one time?

Thanks!

Resolving patch:
diff --git a/spyder/plugins/maininterpreter.py b/spyder/plugins/maininterpreter.py
--- a/spyder/plugins/maininterpreter.py
+++ b/spyder/plugins/maininterpreter.py
@@ -139,27 +139,24 @@ def python_executable_changed(self, pyexec):
         """Custom Python executable value has been changed"""
         if not self.cus_exec_radio.isChecked():
             return
+        def_pyexec = get_python_executable()
         if not is_text_string(pyexec):
             pyexec = to_text_string(pyexec.toUtf8(), 'utf-8')
-        if programs.is_python_interpreter(pyexec):
-            self.warn_python_compatibility(pyexec)
-        else:
+        if pyexec == def_pyexec:
+            return
+        if (not programs.is_python_interpreter(pyexec) or
+                not self.warn_python_compatibility(pyexec)):
             QMessageBox.warning(self, _('Warning'),
                     _("You selected an invalid Python interpreter for the "
                       "console so the previous interpreter will stay. Please "
                       "make sure to select a valid one."), QMessageBox.Ok)
-            self.pyexec_edit.setText(get_python_executable())
+            self.pyexec_edit.setText(def_pyexec)
             return
 
     def python_executable_switched(self, custom):
         """Python executable default/custom radio button has been toggled"""
-        def_pyexec = get_python_executable()
-        cust_pyexec = self.pyexec_edit.text()
-        if not is_text_string(cust_pyexec):
-            cust_pyexec = to_text_string(cust_pyexec.toUtf8(), 'utf-8')
-        if def_pyexec != cust_pyexec:
-            if custom:
-                self.warn_python_compatibility(cust_pyexec)
+        if custom:
+            self.python_executable_changed(self.pyexec_edit.text())
 
     def warn_python_compatibility(self, pyexec):
         if not osp.isfile(pyexec):
@@ -171,6 +168,8 @@ def warn_python_compatibility(self, pyexec):
             console_version = int(proc.communicate()[0])
         except IOError:
             console_version = spyder_version
+        except ValueError:
+            return False
         if spyder_version != console_version:
             QMessageBox.warning(self, _('Warning'),
                 _("You selected a <b>Python %d</b> interpreter for the console "
@@ -180,6 +179,7 @@ def warn_python_compatibility(self, pyexec):
                   "seeing false warnings and errors due to the incompatible "
                   "syntax between these two Python versions."
                   ) % (console_version, spyder_version), QMessageBox.Ok)
+        return True
 
     def set_umr_namelist(self):
         """Set UMR excluded modules name list"""


Test patch: