spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.22k stars 1.59k forks source link

UnicodeDecodeError when changing PYTHONPATH in Python 2 #7236

Closed muuky closed 5 years ago

muuky commented 6 years ago

Problem Description

What steps will reproduce the problem?

after reseting my spyder with "spyder --reset" command and add new path with PYTHONPATH manager. my path is "C:\User\AADL\code\actools\database"

i dont know why this is happening

with adding any path, trigger this problem

Traceback

  File "C:\Users\AADL\Anaconda3\envs\python2_14\lib\site-packages\spyder\plugins\__init__.py", line 514, in <lambda>
    toggled=lambda checked: self.toggle_view(checked),
  File "C:\Users\AADL\Anaconda3\envs\python2_14\lib\site-packages\spyder\plugins\ipythonconsole.py", line 725, in toggle_view
    self.create_new_client(give_focus=False)
  File "C:\Users\AADL\Anaconda3\envs\python2_14\lib\site-packages\spyder\plugins\ipythonconsole.py", line 1046, in create_new_client
    self.connect_client_to_kernel(client, is_cython=is_cython)
  File "C:\Users\AADL\Anaconda3\envs\python2_14\lib\site-packages\spyder\plugins\ipythonconsole.py", line 1074, in connect_client_to_kernel
    is_cython=is_cython)
  File "C:\Users\AADL\Anaconda3\envs\python2_14\lib\site-packages\spyder\plugins\ipythonconsole.py", line 1498, in create_kernel_manager_and_kernel_client
    if not kernel_spec.env.get('PYTHONPATH'):
  File "C:\Users\AADL\Anaconda3\envs\python2_14\lib\site-packages\spyder\utils\ipython\kernelspec.py", line 91, in env
    drop_env=(not default_interpreter))
  File "C:\Users\AADL\Anaconda3\envs\python2_14\lib\site-packages\spyder\utils\misc.py", line 256, in add_pathlist_to_PYTHONPATH
    pypath =  {'PYTHONPATH': pathstr + os.pathsep + old_pypath,
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 59: ordinal not in range(128)

Package Versions

Dependencies

pyflakes >=0.5.0  :  1.6.0 (OK)
pycodestyle >=2.3 :  2.3.1 (OK)
pygments >=2.0    :  2.2.0 (OK)
pandas >=0.13.1   :  None (NOK)
numpy >=1.7       :  1.14.0 (OK)
sphinx >=0.6.6    :  1.7.2 (OK)
rope >=0.9.4      :  0.10.7 (OK)
jedi >=0.9.0      :  0.11.1 (OK)
nbconvert >=4.0   :  5.3.1 (OK)
sympy >=0.7.3     :  None (NOK)
cython >=0.21     :  None (NOK)
qtconsole >=4.2.0 :  4.3.1 (OK)
IPython >=4.0;<6.0:  5.4.1 (OK)
pylint >=0.25     :  1.8.2 (OK)
ccordoba12 commented 6 years ago

What's your current PYTHONPATH? You can get it by evaluating in a console:

import os
os.environ['PYTHONPATH']
muuky commented 6 years ago

image

after ""os.environ['PYTHONPATH'] "" i got this output but in the image there is no such path 'C:\Users\AADL\Desktop\code\actools;D:\mukyeom\LAB\# 03 PAV \xea\xb2\xbd\xec\xa7\x84?\x80??code\actools;D:\mukyeom\LAB\datafusion program\datafusion'

ccordoba12 commented 6 years ago

Although the entry you're trying to add doesn't have Unicode chars, the second entry certainly has them, and that's the problem. Maybe you're unable to have non-ascii paths in your PYHTONPATH in Python 2

muuky commented 6 years ago

now i know this is Unicode problem.... but after that error any path cannot be add to PYTHONPATH even desktop folder itself.

ccordoba12 commented 6 years ago

Perhaps you need to reset your PYTHONPATH using regedit.

muuky commented 6 years ago

can you teach me how to do that?

ccordoba12 commented 6 years ago

@dalthviz, please take a look at this one.

dalthviz commented 6 years ago

@muuky maybe this could help to manage your enviromental variables (including PYTHONPATH).

ccordoba12 commented 6 years ago

@dalthviz, we need to avoid users to make PYTHONPATH entries with unicode characters in our dialog. I think that would be the solution to this problem.