Import numpy throws error: SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \uXXXX escape

前端 未结 3 1914
难免孤独
难免孤独 2020-12-16 23:42

I have installed pyzo and miniconda under Windows 10 and installed numpy and matplotlib using conda install.

3条回答
  •  忘掉有多难
    2020-12-17 00:24

    When conda installs packages, it replaces the prefix, to make things relocatable. Unfortunately, it does not intelligently escape backslashes, so on Windows, these unescaped backslashes lead to the error you see.

    In recent versions of conda, we use forward slashes in prefix replacement, and this issue goes away. If you can update conda, go do that. If not, numpy has prefixes in the following files:

    "Lib/site-packages/numpy/distutils/site.cfg"
    "Scripts/f2py.py"
    "Lib/site-packages/numpy/config.py"
    "Lib/site-packages/numpy/distutils/config.py"
    

    check the latter 3 especially, and replace any non-escaped backslashes ( \ ) with either escaped ones ( \\ ) or forward slashes

提交回复
热议问题