2

I have an accent in my Windows username Clément. Therefore, there is an accent in my user directory C:\Users\Clément\. This causes some troubles for softwares and libraries.

For example, I recently installed Python Anaconda and I can't import the packages (matplotlib, nltk,...) without having a UnicodeDecodeError because of the path.

My question is: Is it possible to remove the accent of the Windows username and change C:\Users\Clément\ to C:\Users\Clement\ without having troubles with the other softwares? Or should I reinstall Windows?

clemtoy
  • 1,681
  • 2
  • 18
  • 30
  • Why wouldn't you use relative instead of absolute paths? Or set the root directory of your Python script to your user's profile directory? –  Jul 20 '15 at 19:54
  • 1
    @Nasha I can't prevent the softwares to use absolute path. I can't rewrite their code! – clemtoy Jul 20 '15 at 20:00
  • A rule of thumb with Python under Windows environments is to install packages in a sub-directory of a drive, such as there's no special character and no space, only ASCII. IIRC it is also specified in the documentation best practices. Renaming Windows accounts is troublesome. I'd advise reinstalling Python and its packages *outside* the user's profile instead. –  Jul 20 '15 at 20:04
  • @Nasha Anaconda didn't let me choose... And I need Anaconda because Numpy is hard to install manually on Windows (compilation needed) – clemtoy Jul 20 '15 at 20:14
  • As per [the documentation](http://docs.continuum.io/anaconda/install.html#windows-install) you *can* select a different destination directory for Anaconda. Normally you should install Python in smth like C:\Python and the rest should follow in subdirectories from there. Have you tried that? Also why do you have to install Numpy manually? Don't any of the installers work? –  Jul 20 '15 at 20:47
  • @Nasha Yes the documentation say that you can choose where to install Anaconda and I have installed it in `C:\Program Files` to avoid issues but the data of some libraries are stored in the user directory (e.g. `C:\Users\Clément\.matplotlib`) and you cannot choose that as far as I know. – clemtoy Jul 20 '15 at 21:08
  • @Nasha As far as I know there is no Numpy installer: you have to build it by yourself (?) Another solution is to let a distribution (e.g. Anaconda) build it for you... – clemtoy Jul 20 '15 at 21:11
  • There actually is no need for binary installers in fact. You can use pypy for instance or python setup utilities to download and install Python packages. Python comes with its own installation utilities that take care of directories and proper naming conventions. But your Python installation must be properly installed in a directory without spaces and ASCII characters first. –  Jul 20 '15 at 21:18
  • Otherwise as a last resort you could a) reinstall everything as a new user without accents or b) use [Junction](https://technet.microsoft.com/en-us/sysinternals/bb896768.aspx) to link a non-accented directory with your user name in C:\Users. –  Jul 20 '15 at 21:21
  • [This topic](http://stackoverflow.com/questions/1449494/how-do-i-install-python-packages-on-windows) should help. –  Jul 20 '15 at 21:25

1 Answers1

1

A much easier solution would be to use Anaconda3, which is based on Python 3. Python 3 handles Unicode strings natively, and it's much rarer to see issues with non-ASCII characters in paths.

asmeurer
  • 86,894
  • 26
  • 169
  • 240