From 1b92c8d5d591bcd248a3012feaa894afbb6f2e92 Mon Sep 17 00:00:00 2001 From: ines Date: Mon, 10 Apr 2017 17:49:49 +0200 Subject: [PATCH] Use unicode paths on Windows/Python 2 and catch other errors (resolves #970) try/except here is quite dirty, but it'll at least make sure users see an error message that explains what's going on --- spacy/cli/link.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/spacy/cli/link.py b/spacy/cli/link.py index 82d1d9a33..a92d809f5 100644 --- a/spacy/cli/link.py +++ b/spacy/cli/link.py @@ -46,8 +46,18 @@ def symlink(model_path, link_name, force): # Add workaround for Python 2 on Windows (see issue #909) if util.is_python2() and util.is_windows(): import subprocess - command = ['mklink', '/d', link_path, model_path] - subprocess.call(command, shell=True) + command = ['mklink', '/d', unicode(link_path), unicode(model_path)] + try: + subprocess.call(command, shell=True) + except: + # This is quite dirty, but just making sure other Windows-specific + # errors are caught so users at least see a proper error message. + util.sys_exit( + "Creating a symlink in spacy/data failed. You can still import " + "the model as a Python package and call its load() method, or " + "create the symlink manually:", + "{a} --> {b}".format(a=unicode(model_path), b=unicode(link_path)), + title="Error: Couldn't link model to '{l}'".format(l=link_name)) else: link_path.symlink_to(model_path)