I am currently working on a workflow that requires the python package 'statsmodels'. I get this error when I try to import this library:
--------------------------------------------------------------------------- ModuleNotFoundError Traceback (most recent call last) <ipython-input-24-9ceb4aea083e> in <module>() ----> 1 import statsmodels.api c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\statsmodels\api.py in <module>() 3 from . import tools 4 from .tools.tools import add_constant, categorical ----> 5 from . import regression 6 from .regression.linear_model import OLS, GLS, WLS, GLSAR 7 from .regression.recursive_ls import RecursiveLS c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\statsmodels\regression\__init__.py in <module>() ----> 1 from .linear_model import yule_walker 2 3 from statsmodels import PytestTester 4 test = PytestTester() 5 c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\statsmodels\regression\linear_model.py in <module>() 46 cache_readonly, 47 cache_writable) ---> 48 import statsmodels.base.model as base 49 import statsmodels.base.wrapper as wrap 50 from statsmodels.emplike.elregress import _ELRegOpts c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\statsmodels\base\model.py in <module>() 13 from statsmodels.tools.sm_exceptions import ValueWarning, \ 14 HessianInversionWarning ---> 15 from statsmodels.formula import handle_formula_data 16 from statsmodels.compat.numpy import np_matrix_rank 17 from statsmodels.base.optimizer import Optimizer c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\statsmodels\formula\__init__.py in <module>() 3 4 ----> 5 from .formulatools import handle_formula_data c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\statsmodels\formula\formulatools.py in <module>() 1 from statsmodels.compat.python import iterkeys 2 import statsmodels.tools.data as data_util ----> 3 from patsy import dmatrices, NAAction 4 import numpy as np 5 ModuleNotFoundError: No module named 'patsy'
So I tried to install this patsy module with Alteryx.installPackages('patsy') and that results in the error:
Collecting patsy Cache entry deserialization failed, entry ignored Downloading https://files.pythonhosted.org/packages/ea/0c/5f61f1a3d4385d6bf83b83ea495068857ff8dfb89e74824c6e9eb63286d8/patsy-0.5.1-py2.py3-none-any.whl (231kB) Requirement already satisfied: numpy>=1.4 in c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages (from patsy) Requirement already satisfied: six in c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages (from patsy) Installing collected packages: patsy Exception: Traceback (most recent call last): File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\pip\basecommand.py", line 215, in main status = self.run(options, args) File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\pip\commands\install.py", line 342, in run prefix=options.prefix_path, File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\pip\req\req_set.py", line 784, in install **kwargs File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\pip\req\req_install.py", line 851, in install self.move_wheel_files(self.source_dir, root=root, prefix=prefix) File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\pip\req\req_install.py", line 1064, in move_wheel_files isolated=self.isolated, File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\pip\wheel.py", line 345, in move_wheel_files clobber(source, lib_dir, True) File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\pip\wheel.py", line 316, in clobber ensure_dir(destdir) File "c:\program files\alteryx\bin\miniconda3\pythontool_venv\lib\site-packages\pip\utils\__init__.py", line 83, in ensure_dir os.makedirs(path) File "C:\Program Files\Alteryx\bin\Miniconda3\lib\os.py", line 220, in makedirs mkdir(name, mode) PermissionError: [WinError 5] Access is denied: 'c:\\program files\\alteryx\\bin\\miniconda3\\pythontool_venv\\Lib\\site-packages\\patsy' --------------------------------------------------------------------------- CalledProcessError Traceback (most recent call last) <ipython-input-23-af54b9079754> in <module>() ----> 1 Alteryx.installPackages('patsy') c:\program files\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:\program files\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 C:\Program Files\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 C:\Program Files\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:\\program files\\alteryx\\bin\\miniconda3\\pythontool_venv\\scripts\\python.exe', '-m', 'pip', 'install', 'patsy']' returned non-zero exit status 2.
What can I do to get access to statsmodels in Alteryx?
Solved! Go to Solution.
Hey @pimp_fada
Could you try installing patsy from the command prompt and see if that works?
1. Run command prompt as administrator
2. cd "C:\Program Files\Alteryx\bin\Miniconda3\PythonTool_venv\Scripts"
3. activate pythontool_env
4. pip install patsy
I will try that and report
Thank you! that works for me.