Spyder: Error when changing the Python interpreter to Python 2

Created on 10 Feb 2020  路  9Comments  路  Source: spyder-ide/spyder

Description

I want to change the python interpreter to python2.However, an error occurred after setting.Specific steps are as follows:
step 1.choose 'Preference' -> 'Python interpreter'
step 2.change the python interpreter to python2 and click the button named 'Apply' or 'OK'

Traceback

  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\preferences\configdialog.py", line 236, in button_clicked
    configpage.apply_changes()
  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\preferences\configdialog.py", line 99, in apply_changes
    self.apply_callback()
  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\preferences\configdialog.py", line 282, in <lambda>
    self.apply_settings(self.changed_options))
  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\preferences\maininterpreter.py", line 257, in apply_settings
    change = self.python_executable_changed(executable)
  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\preferences\maininterpreter.py", line 161, in python_executable_changed
    not self.warn_python_compatibility(pyexec)):
  File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\preferences\maininterpreter.py", line 190, in warn_python_compatibility
    ) % (console_version, spyder_version), QMessageBox.Ok)
TypeError: not all arguments converted during string formatting

Versions

  • Spyder version: 4.0.1
  • Python version: 3.7.4
  • Qt version: 5.12.2
  • PyQt5 version: 5.12.1
  • Operating System: Windows 7

Dependencies

atomicwrites >=1.2.0         :  1.3.0 (OK)
chardet >=2.0.0              :  3.0.4 (OK)
cloudpickle >=0.5.0          :  1.2.2 (OK)
diff_match_patch >=20181111  :  20181111 (OK)
intervaltree                 :  None (OK)
IPython >=4.0                :  7.8.0 (OK)
jedi =0.14.1                 :  0.14.1 (OK)
nbconvert >=4.0              :  5.6.0 (OK)
numpydoc >=0.6.0             :  0.9.1 (OK)
pexpect >=4.4.0              :  4.8.0 (OK)
pickleshare >=0.4            :  0.7.5 (OK)
psutil >=0.3                 :  5.6.3 (OK)
pygments >=2.0               :  2.4.2 (OK)
pylint >=0.25                :  2.4.2 (OK)
pyls >=0.31.2;<0.32.0        :  0.31.7 (OK)
zmq >=17                     :  18.1.0 (OK)
qdarkstyle >=2.7             :  2.8 (OK)
qtawesome >=0.5.7            :  0.6.0 (OK)
qtconsole >=4.6.0            :  4.6.0 (OK)
qtpy >=1.5.0                 :  1.9.0 (OK)
rtree >=0.8.3                :  0.9.3 (OK)
sphinx >=0.6.6               :  2.2.0 (OK)
spyder_kernels >=1.8.1;<2.0.0:  1.8.1 (OK)
watchdog                     :  None (OK)
cython >=0.21                :  0.29.13 (OK)
matplotlib >=2.0.0           :  3.1.1 (OK)
numpy >=1.7                  :  1.16.5 (OK)
pandas >=0.13.1              :  0.25.1 (OK)
scipy >=0.17.0               :  1.3.1 (OK)
sympy >=0.7.3                :  1.4 (OK)
Preferences Reproduced Bug v4.1.0

Most helpful comment

@goanpeca Thank you very much. According to your suggestion, I have solved my doubts.

All 9 comments

@dalthviz can you reproduce this one?

@goanpeca @PrinceFPF I'm not being able to reproduce this one. When using a Python 2 interpreter a warning pops-up (explaining that the use of a Python 2 interpreter while Spyder is being run with a Python 3 interpreter isn't the recommended aproach):

image

@PrinceFPF could you upload a .GIF using something like LICECap to understand how the issue is being trigger for you? Also, how did you install the Python 2 interpreter? Did you create another env (that's the way I tested this, ensuring the other env also has all the needed dependencies like spyder-kernels). Any new info to reproduce this is greatly appreciated :)

question-spyder
@dalthviz I have reproduced it once again. For specific operations, please see the gif picture. In addition, the following provides you with a list of my Anconda conda package manager and a list of pip.
conda list
conda list.txt
pip list
pip list.txt

Thanks for the feedback @PrinceFPF ! Could you also share here the list of packages (conda list and pip list) of the env you are using to launch Spyder?

Seems like the problem isn't in the env you have the kernel, and checking the initial trace back of the issue more carefully, seems like it is pointing to the installation you have in your base env.

The only thing I'm seeing is the use of a mirror to get the packages in your py2 env, but I'm unsure if that could cause some issue.

Edit: I was able to reproduce this by changing the language to Chinese!

@goanpeca @dalthviz @ccordoba12 @maraigue Thank you very much for your help. According to your suggestions, I have temporarily switched the IDE environment to English. I look forward to future updates and fixes this BUG. I also look forward to spyder IDE getting better and better in the future.

We'll fix this error in our next version.

@dalthviz @ccordoba12 Hello, I saw your PR number 11540. I tried to modify the spyder.mo and spyder.po files according to your method, which solved my problem. ,However, I also found another problem. After switching the python interpreter, the IPython kernel does not switch automatically, and the IDE must be restarted to take effect.
question2-spyder

@PrinceFPF you don need to restart spyder, but you do need to restart the Console Manually.

We will add a check so we can ask users if they want to have this done for them automatically.

Have you tried retsarting the console by clicking on:

Screen Shot 2020-02-12 at 11 34 21

@goanpeca Thank you very much. According to your suggestion, I have solved my doubts.

Was this page helpful?
0 / 5 - 0 ratings