Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Importing SpaCy in python tool

Lunalight
7 - Meteor

Hi, 

 

When I try to install Spacy in the Python tool with Alteryx.installPackage('spacy') I get a CalledProcessError. 

I'm running Alteryx as administrator since I saw that mentioned in a thread on installing NLTK. However, it's not solving my problem. How do I go about installing SpaCy in the Python tool?

 

 
---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
<ipython-input-5-996d7f70005a> in <module>()
      1 from ayx import Alteryx
      2 
----> 3 Alteryx.installPackage('spacy')

c:\users\x\appdata\local\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\ayx\export.py in installPackage(package, *args, **kwargs)
     33     This function will install a package or list of packages into the virtual environment used by the Python tool. If using an admin installation of Alteryx, you must run Alteryx as administrator in order to use this function and install packages.
     34     '''
---> 35     __installPackages__(package, *args, **kwargs)
     36 
     37 # these are the same function.

c:\users\x\appdata\local\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\ayx\Package.py in installPackages(package, install_type)
     64         result = subprocess.check_output(
     65             [sys.executable, "-m", "pip"] + pip_args_list,
---> 66             stderr = subprocess.STDOUT
     67             )
     68         # print the output

~\AppData\Local\Alteryx\bin\Miniconda3\lib\subprocess.py in check_output(timeout, *popenargs, **kwargs)
    334 
    335     return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
--> 336                **kwargs).stdout    337 
    338 

~\AppData\Local\Alteryx\bin\Miniconda3\lib\subprocess.py in run(input, timeout, check, *popenargs, **kwargs)
    416         if check and retcode:
    417             raise CalledProcessError(retcode, process.args,
--> 418                                      output=stdout, stderr=stderr)    419     return CompletedProcess(process.args, retcode, stdout, stderr)
    420 

CalledProcessError: Command '['c:\\users\\x\\appdata\\local\\alteryx\\bin\\miniconda3\\pythontool_venv\\scripts\\python.exe', '-m', 'pip', 'install', 'spacy']' returned non-zero exit status 1.
13 REPLIES 13
StephenR
Alteryx
Alteryx

If you are having trouble installing a Python library using the tool, you can use Elevated Command Prompt.

 

cd "C:\Program Files\Alteryx\bin\Miniconda3\PythonTool_venv\Scripts"
activate pythontool_venv
pip install SpaCy
Regards,
Stephen Ruhl
Principal Customer Support Engineer

Lunalight
7 - Meteor

When I try that I get the error Microsoft Visual C++ 14.0 is required even though it is already installed on my laptop. I have Spacy installed with conda on my laptop, but this is a whole folder. Can I just copy it to \PythonTool_venv\Scripts? 

StephenR
Alteryx
Alteryx

Alteryx will not use conda environments and just copy/pasting a folder will probably cause problems. I would try uninstalling and reinstalling Microsoft Visual C++ then reinstalling with pip. My Visual C++ is from my installation of Microsoft Visual Studio 2017. I don't know if that's different from what you have. Also, be sure that you're running Command Prompt as administrator. I ran into an error installing when I ran it non-elevated.

Regards,
Stephen Ruhl
Principal Customer Support Engineer

Lunalight
7 - Meteor

The command prompt installs everything in the anaconda folder instead of C:\Users\x\AppData\Local\Alteryx\bin\Miniconda3\PythonTool_venv\Scripts

Lunalight
7 - Meteor

Ok fixed the problem. I had to run 

pip install -U setuptools

After this together with running command as admin worked like a charm!  

StephenR
Alteryx
Alteryx

Did you activate the environment? In order to use pip to install to a venv, that specific environment must be active. Otherwise it will install to the lowest level Python environment it can find.

Regards,
Stephen Ruhl
Principal Customer Support Engineer

Yamani_Kakarla
5 - Atom

Hi,

 

I was able to install SpaCy successfully. Running the following command,

 

nlp = spacy.load('en') 

 

throws an error. The following is the error message,

 

 [E050] Can't find model 'en'. It doesn't seem to be a shortcut link, 
a Python package or a valid path to a data directory.

I downloaded the spacy ("en")  model and it showed this,

 

Requirement already satisfied: en_core_web_sm==2.0.0 
from https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0/en_core_web_sm-2.0....
in c:\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages Linking successful c:\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\en_core_web_sm --> c:\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\spacy\data\en You can now load the model via spacy.load('en')

 Though it shows the model can loaded, i'm unable to load the model. Can anyone suggest a solution?

Yamani_Kakarla
5 - Atom

This is resolved. I used the following command,

 

nlp = spacy.load('en_core_web_sm')

 

coderockride
8 - Asteroid

Neither load option seems to work for me. Any suggestions?

spacy load error.PNG

Labels