Sitecustomize fails when current directory has non-ascii chars
See original GitHub issueDescription
What steps will reproduce the problem?
- Start Spyder.
- Open any *.py file.
- Close Spyder.
- Open again.
What is the expected output? What do you see instead?
The internal python console shows the message “‘import sitecustomize’ failed” and stops loading any further. No commands can be executed. After running spyder --reset it loads normally until the next startup after I had a file opened.
Please provide any additional information below
Version and main components
- Spyder Version: 2.3.8
- Python Version: 2.7.12
- Qt Versions: 4.8.7, PyQt4 (API v2) 4.11.4 on Linux
Optional dependencies
pyflakes >=0.5.0 : 1.1.0 (OK)
pep8 >=0.6 : None (NOK)
pygments >=1.6 : 2.1 (OK)
IPython >=1.0 : 2.4.1 (OK)
zmq >=2.1.11 : 15.2.0 (OK)
pandas >=0.13.1 : 0.17.1 (OK)
sphinx >=0.6.6 : 1.3.6 (OK)
psutil >=0.3 : 3.4.2 (OK)
rope >=0.9.2 : 0.10.2 (OK)
jedi >=0.8.1;<0.9.0: 0.9.0 (NOK)
matplotlib >=1.0 : 1.5.1 (OK)
sympy >=0.7.3 : None (NOK)
pylint >=0.25 : 1.5.2 (OK)
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (7 by maintainers)
Top Results From Across the Web
Error with non-ASCII character? - Python Forum
Using 3.9.0 under Windows 10. I get an error with "pip install pyinstaller" as below (my username REDACTED in this excerpt):
Read more >Spyder can't start if user's home directory contains non-ASCII ...
UnicodeEncodeError: 'ascii' codec can't encode characters in position ... During console startup I'm getting 'import sitecustomize failed'.
Read more >Add sitecustomize.py to set Python default encoding to UTF-8
There is no problem related to this change with users who use only ASCII characters. In Python 3.x, the default encoding is UTF-8....
Read more >UnicodeError: URL contains non-ASCII characters (Python 2.7)
So I've managed to make a crawler, and I'm searchng for all links and when I arrive at a product link I make...
Read more >Pip install Unicode error when having non-ASCII characters in ...
Basically pip install can not install some packages on windows if you have non-ASCII characters in your user folder name (cyrillic in my ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

So, finally back at work, here is the more exact error description:
I open Spyder, I change to a working directory (via GUI) that has special characters (in my case, the german version of ‘Desktop’, which is ‘Arbeitsfläche’). As soon, as I do that, the debug shell throws the following exception:
Traceback (most recent call last): File “/home/user/.local/lib/python2.7/site-packages/spyder/plugins/ipythonconsole.py”, line 845, in set_current_client_working_directory shellwidget.set_cwd(directory) File “/home/user/.local/lib/python2.7/site-packages/spyder/widgets/ipythonconsole/shell.py”, line 87, in set_cwd “get_ipython().kernel.set_cwd(r’{}')”.format(dirname)) UnicodeEncodeError: ‘ascii’ codec can’t encode character u’\xe4’ in position 23: ordinal not in range(128)
When I close Spyder in this state and restart it (without resetting), the debug shell shows:
Traceback (most recent call last): File “/home/user/anaconda2/lib/python2.7/site.py”, line 498, in execsitecustomize import sitecustomize File “/home/user/.local/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py”, line 241, in <module> import matplotlib File “/home/user/anaconda2/lib/python2.7/site-packages/matplotlib/init.py”, line 1138, in <module> rcParams = rc_params() File “/home/user/anaconda2/lib/python2.7/site-packages/matplotlib/init.py”, line 971, in rc_params fname = matplotlib_fname() File “/home/user/anaconda2/lib/python2.7/site-packages/matplotlib/init.py”, line 786, in matplotlib_fname cwd = os.getcwdu() UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0xc3 in position 23: ordinal not in range(128)
leading to a failing import of sitecustomize and therefore unstable internal console. Resetting solves the problem (as I guess, it resets the current working directory to a default, without special characters).
?Hi Daniel,
Opening and closing Spyder works reliable. However, the import sitecustomize fails, with the aforementioned traceback.
The error is clearly “ordinal not in range” when closing spyder while in a working directory with non-ascii characters.
This leaves spyder in a “kind-of-working” state, but the internal python console doesn’t work.
It is no matter of a firewall, as we are on Ubuntu without any firewall.
I’ll send the full stack trace as soon as possible.
Von: Daniel Althviz Moré notifications@github.com Gesendet: Freitag, 9. Dezember 2016 00:25 An: spyder-ide/spyder Cc: Schock, Jonathan; Mention Betreff: Re: [spyder-ide/spyder] Sitecustomize fails when current directory has non-ascii chars (#3407)
Hi again @Dschonihttps://github.com/Dschoni, it’s really strange that it worked for you (at least to close and open Spyder), and then it stopped working. Searching a little bit I think that maybe your problem is about the configuration of your firewall like in this posthttp://stackoverflow.com/q/17258634. From there are some steps that you can follow:
Can you see if following these steps make Spyder work again? I will open a new issue for the new error that you post when you ran Spyder 3.0.2. Also if you can use the -v option to print the traceback and paste it here would be great.
You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/spyder-ide/spyder/issues/3407#issuecomment-265886585, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AH3ba-SjpClQJrqvOHBjtiCMU8FC-sguks5rGJHggaJpZM4J10sI.