1

I am trying to run some very basic python code which works perfectly under spyder, on the last version of Pycharm:

a = 2
print a

Here is the error message I get:

File "C:\Users\Fran�ois\Anaconda\lib\ntpath.py", line 84, in join
    result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe7 in position 11: ordinal not in range(128)

Process finished with exit code 1

As you see, Pycharm can not handle the fact that one of my folder is called "François" (french first name) and since my interpreter is in this folder, it launches an error.

My Pycharm python interpreter path is set to the following:

C:\Users\François\Anaconda\Python.exe

So how can I solve this problem without renaming any folder in my computer? I do not have access to move the interpreter to another location. I looked at the options but I couldn't figure it out.

admdrew
  • 3,790
  • 4
  • 27
  • 39
sweeeeeet
  • 1,769
  • 4
  • 26
  • 50
  • How are you opening the file? If this is Python 3, you'll need to add an explicit `encoding` flag, like this: `open(filename, encoding="utf8")`. – admdrew Dec 05 '14 at 18:04
  • I just execute the code, I am not even opening a file in my code, and the error is not a Python error since my code works under spyder. The problem is that Pycharm can't even understand the "ç". Am i clear? So no, It not a duplicate. – sweeeeeet Dec 05 '14 at 18:15
  • Yes. I have had this exact problem before, it's a *python* issue, not with the Pycharm IDE itself. What version of python are you using, and what is your *exact* code you're trying to execute? – admdrew Dec 05 '14 at 18:16
  • It is Python 2.7 but as I tell you, it works under the Spyder IDE. My pycharm is compatible with 2.7 python. – sweeeeeet Dec 05 '14 at 18:17
  • Which interpreter is Pycharm using? (Preferences->Project Interpreter->Python Interpreters) – admdrew Dec 05 '14 at 18:18
  • Is is using the C:/Users/François/Anaconda/Python.exe interpreter – sweeeeeet Dec 05 '14 at 18:22
  • Can you verify that python version? And did you take a look at this question/answer?: http://stackoverflow.com/questions/18828265/unicodedecodeerror-in-pycharm-debugger – admdrew Dec 05 '14 at 18:26
  • I can't even run a single bit of code, I always have the same error. Looks like Pycharm can't access to the interpeter since it is in a file called 'François'. – sweeeeeet Dec 05 '14 at 18:30
  • Ah, very interesting. I think first step would be to change the location of the interpreter (or, do you not have local admin access?). – admdrew Dec 05 '14 at 18:31
  • 1
    I can't move the interpreter, I don't have the rights. That's why I have to find an option or something? – sweeeeeet Dec 05 '14 at 18:33
  • As a workaround, how about creating a shortcut (in windows explorer) that points to the interpreter and has no ascii chars in its path ? And pass that to Pycharm – Arnaud P Dec 05 '14 at 19:23
  • Pycharm does not accept shortcuts from Windows explorer :( – sweeeeeet Dec 05 '14 at 19:33
  • *"Pycharm does not accept shortcuts from Windows explorer "* But it accepts symbolic links ... – LazyOne Dec 09 '14 at 12:28

0 Answers0