tableau / TabPy

Execute Python code on the fly and display results in Tableau visualizations:
https://tableau.github.io/TabPy/
MIT License
1.56k stars 598 forks source link

LoadFailed: "Load failed: No module named 'tabpy_client'" #264

Closed caitlyngUR closed 5 years ago

caitlyngUR commented 5 years ago

I am getting the following error when I go to publish a neural network model I had created to the TabPy localhost server:

LoadFailed Error

I have already imported the module as so... import tabpy_client

I even tried appending the PATH of the module to see if that would fix the issue...

Path

And I have called the tabpy_client.Client previously with no error/warning: connection = tabpy_client.Client('http://localhost:9004/')

I have already successfully connected to the localhost server through Tableau so it should run without a problem.

Successful Connection to Localhost

I am not sure as to what might be the issue. Any help would be fantastic!!

0golovatyi commented 5 years ago

@caitlyngUR What release of TabPy are you running? You can confirm it with curl localhost:9004/info command. For newer versions of TabPy it is tabpy_tools you need to use, see more details here - https://github.com/tableau/TabPy/blob/master/docs/tabpy-tools.md. You may need to run pip install -e tabpy-tools first for the steps to work.

caitlyngUR commented 5 years ago

I am running version 0.4

0golovatyi commented 5 years ago

@caitlyngUR try pip install -e tabpy-tools from the repo root folder to install tabpy-tools package and then follow the steps mentioned at https://github.com/tableau/TabPy/blob/master/docs/tabpy-tools.md.

caitlyngUR commented 5 years ago

@0golovatyi forgive me if this is trivial but I successfully installed in the Tabpy-master folder Tabpy-tools

I went through the the detailed post that you sent and everything seems to be in order but I am still getting the same error.

0golovatyi commented 5 years ago

@caitlyngUR the main difference is you need to import tabpy-tools and not tabpy-client

caitlyngUR commented 5 years ago

Sorry, this is the error I am getting...

Tabpy-tools no module

nmannheimer commented 5 years ago

Hi @caitlyngUR, are you running Jupyter in Anaconda? Is it possible that you are using multiple virtual environments and your Jupyter notebook is running in a different environment than the one you installed TabPy to?

caitlyngUR commented 5 years ago

@nmannheimer I am running Jupyter in Anaconda but I only have the one base environment.

nmannheimer commented 5 years ago

Is that environment also where you installed TabPy? Ie did you run the 'activate ...' command before installing TabPy?

caitlyngUR commented 5 years ago

@nmannheimer yes it is installed in the same base(root) environment

0golovatyi commented 5 years ago

@caitlyngUR Let's try this:

caitlyngUR commented 5 years ago

@0golovatyi Okay that seemed to fix the original issue but then I am getting the following error:

1st Time I ran it: Load failed: No module name 'sklearn'

2nd time: Load failed: No module name 'keras'

When I import both of these in the beginning of the script I don't run into any errors

0golovatyi commented 5 years ago

@caitlyngUR For all the modules you use in your model you need to install them for your Python environment with pip, e.g. pip install sklearn

caitlyngUR commented 5 years ago

@0golovatyi I have them both installed and imported. They aren't throwing any errors throughout my script until I try and deploy the connection to TabPy server.

0golovatyi commented 5 years ago

I would guess it means you run TabPy and your deployment code in different Python environments. If you stop running TabPy instance and run pip list you can see if the packages are installed. And if they are not you'll need either to install them or use the same Python environment for both TabPy server and tabpy-tools deployment script.

caitlyngUR commented 5 years ago

So all of the modules seem to installed in the same environment:

pip list code

pip list keras

pip list scikit

pip list tabpy

But yet still getting this error: sklearn load failed

0golovatyi commented 5 years ago

I see console screenshot (is it Anaconda env?) and some other env (is it Jupiter or something similar)? My theory is the env you run deployment script is not the same as the env where tabpy server runs. If you run python from command line in the same console where you run pip you should be able to execute import sklearn to prove the package can be used in that env.

caitlyngUR commented 5 years ago

@0golovatyi thank you! I seemed to have fixed that problem now. The Jupyter notebook runs with no errors but when I try to use the following calculation in Tableau it throws the following error:

Wine Suggestion Calc

Calc Errors Message

I checked the localhost:9004/endpoints where my TabPy server is running:

9004 endopoints

And this is the error from the command line:

cmd error

I've also checked to see if my model/function from Jupyter Notebook works and it seems to be working fine:

code check

nmannheimer commented 5 years ago

Hi @caitlyngUR when Tableau passes variables they are sent as lists to python, not single values (scalars). Looking at your code in block 20 in the last image you sent, it looks like you are expecting to receive single values in your function, so I suspect the lack of response from the endpoint is due to this. If you add index selectors to your code in your Tableau calculation, ie _arg1[0], _arg2[0], this should fix the problem.

caitlyngUR commented 5 years ago

@nmannheimer I tried adjusting the Tableau Calculation but I am getting the same error

nmannheimer commented 5 years ago

Are you able to query the endpoint from your code as described in the query section here? https://github.com/tableau/TabPy/blob/master/docs/tabpy-tools.md

caitlyngUR commented 5 years ago

endpoint error

endpoint error 2

nmannheimer commented 5 years ago

Hi @caitlyngUR , what happens if you pass the variables individually, ie connection.query('WineQuality', 6, .3, .3,...) instead of as a single tuple query_check? Also just to make sure on the last idea, did you add [0] to all variables in your Python code? Would you mind sending a picture of how your calculation looks now in Tableau?

caitlyngUR commented 5 years ago

Tried this instead connection.query('WineQuality', 6,.3,.3,2,.03,20,100,.98,3,.35,11) but still getting the same error.

Also, here is the calc that still returns this error "Unable to complete action An error occurred while communicating with the External Service. Error processing script The endpoint you're trying to query did not respond. Please make sure the endpoint exists and the correct set of arguments are provided."

new calc

nmannheimer commented 5 years ago

@caitlyngUR that's strange. Are you able to deploy and test a simple function like:

def add(x,y): return x + y

caitlyngUR commented 5 years ago

add deploy

yeah that seems to work fine

nmannheimer commented 5 years ago

Are all of your parameters the correct types that the model is expecting for each field? IE integer or float.

caitlyngUR commented 5 years ago

Yeah all of the parameters are set to datatype= float which is what each of the inputs are... dtypes

Could it be something with how I am returning the value?

So I have the model predicting what quality_bin a wine falls into (0,1,or 2). Then the function returns the inverse encoding: quality_check

And for Tableau I am starting off my calculation with SCRIPT_STR.

nmannheimer commented 5 years ago

Hey @caitlyngUR , is it possible that you could send this jupyter notebook and data to nmannheimer@tableau.com so I can take a look?

The return type looks good, and the fact that you can deploy a simple function shows that TabPy tools is working as expected. Also, what library are you building your model with? Looking up the thread, I noticed you are importing keras, what API is it sitting on top of?

nmannheimer commented 5 years ago

Hi @caitlyngUR , looking through your notebook I believe I've identified the issue: TabPy's model deployment service uses Pickle in Python. As has been documented in another feature request (https://github.com/tableau/TabPy/issues/120), and here: https://keras.io/getting-started/faq/ Keras does not fully support pickling of models. I've tested the same code with an sklearn logistic regression model to confirm that everything else is working as expected. This is something we would like to explore in the future, but as of now models from Keras are not supported by TabPy.

caitlyngUR commented 5 years ago

Ahhh I see. That would solve the problem. Thank you so much for all your help.

Caitlyn Garger | Business Intelligence Analyst C: (516) 474-8814 E: caitlyng@useready.commailto:caitlyng@useready.com [USEReady]http://t.sidekickopen69.com/e1t/c/5/f18dQhb0S7lC8dDMPbW2n0x6l2B9nMJW7t5XYg1p1FbvW1qMLx24WJ7JnW3MPft-56dGvtf7LtlY402?t=http://www.useready.com/&si=6407247951429632&pi=8004520d-daf8-44d0-cb4d-ad5897aab361

FAST TRACKING BUSINESS PERFORMANCE WITH ADVANCED BI, DATA AND SECURITY SOLUTIONS Follow Us: Twitterhttp://t.sidekickopen69.com/e1t/c/5/f18dQhb0S7lC8dDMPbW2n0x6l2B9nMJW7t5XYg1p1FbvW1qMLx24WJ7JnW3MPft-56dGvtf7LtlY402?t=https%3A%2F%2Ftwitter.com%2FUSEReadyInc&si=6407247951429632&pi=8004520d-daf8-44d0-cb4d-ad5897aab361 | Facebookhttp://www.facebook.com/usereadyinc | LinkedInhttp://t.sidekickopen69.com/e1t/c/5/f18dQhb0S7lC8dDMPbW2n0x6l2B9nMJW7t5XYg1p1FbvW1qMLx24WJ7JnW3MPft-56dGvtf7LtlY402?t=https%3A%2F%2Fwww.linkedin.com%2Fcompany%2Fuseready&si=6407247951429632&pi=8004520d-daf8-44d0-cb4d-ad5897aab361

From: nmannheimer notifications@github.com Sent: Monday, April 22, 2019 8:18 PM To: tableau/TabPy TabPy@noreply.github.com Cc: Caitlyn Garger caitlyng@useready.com; Mention mention@noreply.github.com Subject: Re: [tableau/TabPy] LoadFailed: "Load failed: No module named 'tabpy_client'" (#264)

Hi @caitlyngURhttps://github.com/caitlyngUR , looking through your notebook I believe I've identified the issue: TabPy's model deployment service uses Pickle in Python. As has been documented in another feature request (#120https://github.com/tableau/TabPy/issues/120), and here: https://keras.io/getting-started/faq/ Keras does not fully support pickling of models. I've tested the same code with an sklearn logistic regression model to confirm that everything else is working as expected. This is something we would like to explore in the future, but as of now models from Keras are not supported by TabPy.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/tableau/TabPy/issues/264#issuecomment-485596379, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ALWCOXLMJKQ72SYDUTIT5YDPRZITHANCNFSM4HHHN3JA.

sahil0094 commented 4 years ago

@caitlyngUR Let's try this:

  • in cmd navigate to you repo root folder
  • run SET PYTHONPATH=.\tabpy-server;.\tabpy-tools;%PYTHONPATH%
  • start python
  • try you script again

what is repo root folder?Pls help

0golovatyi commented 4 years ago

@sahil0094 There is no repo folder unless you are developing for TabPy. If your scenario is using TabPy for Python script execution during Data Prep or Tableau viz calculation follow these instructions to install and configure TabPy - https://tableau.github.io/TabPy/