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
coderockride
8 - Asteroid

So spacy seems to have installed for me now (I think mine was a certs issue), but I cannot seem to load models. What is the Alteryx Python tool equivalent of the following command?

 

python -m spacy download en_core_web_sm

 

I'm simply trying to follow the "hello world" found at 

 

https://spacy.io/usage/spacy-101#whats-spacy

vic_aug
5 - Atom

Have you found out how to solve it? Even importing it with pip in cmd, alteryx still not recognize spacy.

VIBS
5 - Atom

Hi Stephen,

 

After installing spacy successfully, I am not able to load the package

 

sp = spacy.load('en_core_web_sm') 

 

this gives error as module not found. (I am using Alteryx Designer Non Admin tool).

 

Any suggestions?

 

Regards,

Vibs

VIBS
5 - Atom

The following steps worked for me.

 

from ayx import Package

Package.installPackages(['spacy', 'https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.1.0/en_core_web_sm-2.1....'])

 

import en_core_web_sm

nlp = en_core_web_sm.load()

Labels